Help with mapping ternary relationships (URGENT)

Reply

Join Date: Oct 2008
Posts: 4
Reputation: yugoza is an unknown quantity at this point 
Solved Threads: 0
yugoza yugoza is offline Offline
Newbie Poster

Help with mapping ternary relationships (URGENT)

 
0
  #1
Nov 11th, 2008
Hi all,

I would appreciate any help on the following problem:

I have a one-to-one-to-one ternary relationship where Supervisor “chooses” Student for Project

A supervisor chooses one student for one project (This is going to be the case when there are many students applying for the same project with a particular supervisor. Then, a supervisor can express their preference over students and choose one or the project. Note that he can still choose another student for a different project if he has proposed more than one project.

So, this is the relational schema for the relationship:
Chooses_Student_schema = { user_ID*: INTEGER, project_ID*: INTEGER, user_ID*: INTEGER }

But, the question is - is this how you map it to an SQL table?

  1. CREATE TABLE choosesStudent (
  2. user_ID AS “student_ID” INTEGER NOT NULL AUTO_INCREMENT,
  3. project_ID INTEGER NOT NULL AUTO_INCREMENT,
  4. user_ID AS “supervisor_ID” INTEGER NOT NULL AUTO_INCREMENT,
  5. PRIMARY KEY (student_ID, project_ID),
  6. FOREIGN KEY (student_ID) REFERENCES student,
  7. FOREIGN KEY (project_ID) REFERENCES project,
  8. FOREIGN KEY (supervisor_ID) REFERENCES [B]supervisor OR coordinator[/B],
  9. UNIQUE (student_ID, supervisor_ID),
  10. UNIQUE (project_ID, supervisor_ID));

I have another problem with the bit in bold in the above table: can I reference two tables there? The coordinator entity is a subclass of the supervisor entity.

Many thanks!!
Last edited by peter_budo; Nov 12th, 2008 at 6:08 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Help with mapping ternary relationships (URGENT)

 
0
  #2
Nov 11th, 2008
do supervisors and coordinators exist in different tables?

you can have a fk to two different tables

if they are users, just add a user_type_id to the users table and create a userstype table

with entries of
student
supervisor
coordinator
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Database Design Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC