Re: Problems defining a primary key !!

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Problems defining a primary key !!
Date: 2003-10-07 11:54:11
Message-ID: 20031007135411.B663@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> 1- Table DAY representing a day (day_id,year,month ...)
> 2- Table PERIODE representing an hour of a day (periode_id,starting,ending,periode_number)
> 3- Table TEACHER representing a teacher (teacher_id,name,phone,address ...)
> 4- Table ROOM representing a ROOM in the university (room_id,description,name ...)
> 5- Table COURSE representing a course given by a teacher (course_id,name,...)
>
> following table PLANIFY(day_id,periode_id,teacher_id,room_id,course_id)
>
> THE PROBLEM IS THAT I DON'T HAVE A WAY TO DEFINE A PRIMARY KEY for the table PLANIFY.
You can always define your own primary key with the SERIAL
datatype.

> We must note that:
> 1- a teacher can not give 2 courses in the same peiode on the same day, and can not exist in 2 different rooms in the same periode on the same day.
unique (periode_id, day_id, teacher_id, course_id)
unique (periode_id, day_id, teacher_id, room_id)

> 2- a room can not be occupied by 2 courses or 2 teachers in the same periode on the same day.
unique (periode_id, day_id, room_id, course_id)
unique (periode_id, day_id, room_id, teacher_id) (redundant, see above)

> 3- a course can not be given by 2 teachers or in 2 different rooms
unique (course_id, teacher_id)
unique (course_id, room_id)

Does that help ?

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Johnson, Shaunn 2003-10-07 12:01:11 Re: using copy to load odd characters
Previous Message Bruno BAGUETTE 2003-10-07 11:39:02 mod_auth_pgsql 2.0.2b1 feedbacks