|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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) ); |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Thanks, it makes sence now.
|
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > conceptually wrong tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|