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,mo nth ...)
2- Table PERIODE representing an hour of a day (periode_id,sta rting,ending,pe riode_number)
3- Table TEACHER representing a teacher (teacher_id,nam e,phone,address ...)
4- Table ROOM representing a ROOM in the university (room_id,descri ption,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,teac her_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:
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.
2- a room can not be occupied by 2 courses or 2 teachers in the same periode on the same day.
3- a course can not be given by 2 teachers or in 2 different rooms
ANY IDEAS ??
SHOULD I CHANGE THE STRUCTURE OF THE TABLE OR DEFINE A TRIGGER (which i don't know how to by the way).
thx for any help.
---------------------------------
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search 2 1319
> 1- Table DAY representing a day (day_id,year,mo nth ...) 2- Table PERIODE representing an hour of a day (periode_id,sta rting,ending,pe riode_number) 3- Table TEACHER representing a teacher (teacher_id,nam e,phone,address ...) 4- Table ROOM representing a ROOM in the university (room_id,descri ption,name ...) 5- Table COURSE representing a course given by a teacher (course_id,name ,...)
following table PLANIFY(day_id, periode_id,teac her_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
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org
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,mo nth ...) 2- Table PERIODE representing an hour of a day (periode_id,sta rting,ending,pe riode_number) 3- Table TEACHER representing a teacher (teacher_id,nam e,phone,address ...) 4- Table ROOM representing a ROOM in the university (room_id,descri ption,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,teac her_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,tea cher), but you'll need UNIQUE constraints on
day,period,room and day,period,cour se 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
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jack A |
last post by:
Guys,
I'm stumped. While its not pertinent to the
matter, we are running a Vignette content management
system on Win2k with Sql 2000 Enterprise on a cluster.
The server has 2 Gig of RAM , 2 CPU's and the database
size is 1.5G.
The query below is fired at login. The indexes
seem fine based on the query plan. When I look through
profiler, the query below takes a very high # of CPU
|
by: JMCN |
last post by:
hi-
i have inherited an access 97 database that keeps track of the loans.
i have been running into referential intergrity problems when i try to
append new loans to table.
first of all is a linked table from another ms
database. when i try to run the append query, i receive an error
message that it cannot append all the records due to key violations to
the . so i looked at all of the relationships and
|
by: Jonathan [sbrodolo] |
last post by:
Hi there, I am using a LOTUS/DOMINO Web Service in my ASP.Net application and
I am having quite a lot of problems. I have managed to solve most of them but
this one it really is giving me terrible headaches. Web Service send's me
back an XML that I have managed to read with an enormous quantity of problems
(it sends me back an XML file with double XML declaration, not the real XML
format). In case of server errors, DOMINO sends me back an...
|
by: ckirby |
last post by:
I have a situation where I'm trying to add a text field to allow
large Notes to be linked to record in an existing table (rather than
simply adding the new field into the table since relatively few
records will have the Note)
Tables are basically:
T1
ID InvNumFK
----------------------
|
by: shadowsoulja |
last post by:
okay, ive been going okay on my assignment, but ive just run into a problem.
i need to read a file into my program, the data from the file is to be read, and then randomised to produce "match data" for some matches.
im not too sure on how to do this.
i have tested reading the file in and outputting it onto the program, but it seems to read the data vertically rather than line by line :S which causes even more of a problem.
my code.
| |
by: aviansh |
last post by:
HI Experts,
I have same table structures in two database and one master table which contains Table id, Table name,primary key, data type of primary key. i have to comapare
Tables in both tha database and as per result i have to do insert,update or delete.
for that i have written query :
DECLARE @rowcount_mastertable FLOAT
SET @rowcount_mastertable = (select count(*) from master_table)
|
by: EllieT |
last post by:
Hi all,
I've been fiddling around with creating a new database (Access 2003, Windows XP) for work the past two weeks and am having trouble defining my own customized (yet still automatic) primary key.
I have three different tables that need data inputted (Clients , Complaints , and Queries ) and need individual primary keys for each that are easily identifiable by the first letter and indicative year.
I was hoping for something along...
|
by: msb_6 |
last post by:
Currently I have a PHP extension thats all written and compiles under
windows, but the PC I'm going to end up putting it on is running
Ubuntu 8.04 (g++ 4.2.3).
I've delved into PHP documentation and ended up with a simple
config.m4 file and the process to compile.
However when I try to compile I get loads of errors that I didn't get
when compiling under windows.
I've managed to simplify the code down and create a simple extension
(that...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |