Re: Problems defining a primary key !!

From: Richard Huxton <dev(at)archonet(dot)com>
To: Nagib Abi Fadel <nagib_postgres(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Problems defining a primary key !!
Date: 2003-10-07 12:20:07
Message-ID: 200310071320.07771.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday 07 October 2003 11:38, Nagib Abi Fadel wrote:
> Hi ,
> i'm doing the planification of the courses in a university.
> I have definned the following tables:
>
> 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,...)
>
> Now i have to planify the courses:
> So i created the
> 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. We must note that:

You do (day,period,teacher), but you'll need UNIQUE constraints on
day,period,room and day,period,course too.

Alternatively, two tables (*=primary key)

t1 (day*, period*, teacher*, course)
t2 (day*, period*, course*, room)

You could pick different combinations of p,t,c depending on your model.
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2003-10-07 12:27:06 Re: PostgreSQL Beta4 Tag'd and Bundle'd ...
Previous Message Johnson, Shaunn 2003-10-07 12:01:11 Re: using copy to load odd characters