I think, if it is relationship many-to-many (one admin can be in many
institute, and one institute can has many admin, you should use relation
table, see below.
> -----------------> here we go
> BEGIN; -- begin table transaction -- Only Postgresql
> CREATE TABLE institute_t (
> name VARCHAR(48) PRIMARY KEY,
> street VARCHAR(48) NOT NULL,
> zip VARCHAR(16),
> town VARCHAR(32) NOT NULL,
> country CHAR(2) NOT NULL, /* country codes ISO-3166*/
> phone VARCHAR(32) NOT NULL,
> fax VARCHAR(32),
> admin VARCHAR(16) REFERENCES admin_t
> ON UPDATE CASCADE
> ON DELETE SET NULL
> DEFERRABLE
> INITIALLY DEFERRED
> );
>
create table institute_admin (row int primary key,name varchar(48) references institute_t,login
varchar(16) references admin_t
);
> CREATE TABLE admin_t (
> login VARCHAR(16) PRIMARY KEY,
> password VARCHAR(16) NOT NULL,
> email VARCHAR(32) NOT NULL,
> real_name VARCHAR(32) NOT NULL,
> street VARCHAR(48) NOT NULL,
> zip VARCHAR(16),
> town VARCHAR(32) NOT NULL,
> country CHAR(2) NOT NULL, /* country codes -- refer to
> ISO-3166*/
> phone VARCHAR(32) NOT NULL,
> fax VARCHAR(32),
> access INTEGER NOT NULL,
> institute VARCHAR(48) REFERENCES institute_t
> ON UPDATE CASCADE
> ON DELETE SET NULL
> DEFERRABLE
> INITIALLY DEFERRED
> );
> COMMIT;
>
If you have diffarant relation, describe it.
-----------------------------
Grigoriy G. Vovk