Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 16th, 2004, 04:33 PM
merck merck is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 13 merck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
conceptually wrong tables

I have the following two tables. Even though they work in Oracle I was told that they are conceptually wrong. Can anyone explain me why? Thanks.

CREATE TABLE student (
tech_id INT NOT NULL,
name VARCHAR2(50) NOT NULL,
favorite_prof_id INT,
PRIMARY KEY (tech_id)
);


CREATE TABLE student_advisor (
student_id INT NOT NULL,
prof_id VARCHAR2(10) NOT NULL,
FOREIGN KEY student_id REFERENCES student(tech_id)
ON DELETE SET NULL,
FOREIGN KEY prof_id REFERENCES prof(prof_id)
ON DELETE SET NULL,
PRIMARY KEY (student_id, prof_id)
);

Reply With Quote
  #2  
Old July 18th, 2004, 09:36 PM
gamyers gamyers is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 14 gamyers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The different naming of the tech_id/student_id columns might be confusing.
You haven't specified a 'prof' table in your question, but I'll assume it exists.
I think the 'wrongness' is in the ON DELETE clauses.
Both columns are primary key columns so can never be null so you cannot SET NULL.
In practical terms, when you delete a student, you'll want to delete the related student_advisor records. Not sure what you want to do when you delete a professor. Probably prevent the deletion if there are student_advisor records so that a professors student's have to be 'handed over' to another professor before the original profressor is deleted

Reply With Quote
  #3  
Old July 19th, 2004, 12:02 PM
merck merck is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 13 merck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, it makes sence now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > conceptually wrong tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway