Re: Tabe Relationship
From: Damjan S. Vujnovic <damjan_at_galeb.etf.bg.ac.yu>
Date: Tue, 11 Mar 2003 10:05:44 +0100
Message-ID: <b4kapv$nj8$2_at_news.etf.bg.ac.yu>
>
> Hmm, I must confess I didnt think of that. However, the following might be
> a solution:
>
> create table user (
> user_id integer not null,
> user_type integer not null,
> user_name varchar(20) not null, -- common to all subtypes
> primary key (user_id, user_type),
> check (usertype between 1 and 3)
> )
>
> create table administrator (
> admin_id integer not null,
> user_type integer not null default 1,
> ....
> foreign key (admin_id, user_type)
> references user (user_id, user_type),
> check (usertype = 1)
> )
Date: Tue, 11 Mar 2003 10:05:44 +0100
Message-ID: <b4kapv$nj8$2_at_news.etf.bg.ac.yu>
Lennart Jonsson wrote:
>>What if USER can be both Administrator and Staff (or any other combination)?
>
> Hmm, I must confess I didnt think of that. However, the following might be
> a solution:
>
> create table user (
> user_id integer not null,
> user_type integer not null,
> user_name varchar(20) not null, -- common to all subtypes
> primary key (user_id, user_type),
> check (usertype between 1 and 3)
> )
>
> create table administrator (
> admin_id integer not null,
> user_type integer not null default 1,
> ....
> foreign key (admin_id, user_type)
> references user (user_id, user_type),
> check (usertype = 1)
> )
???
What will be the value of attrubute user_type in relation USER?
Regards,
Damjan S. Vujnovic
University of Belgrade
School of Electrical Engineering
Department of Computer Engineering & Informatics
Belgrade, Serbia
http://galeb.etf.bg.ac.yu/~damjan/ Received on Tue Mar 11 2003 - 10:05:44 CET