Author | Message |
---|---|
Yuan-Yu
Posts: 21
|
Posted 21:17 Feb 05, 2015 |
Hello, In professor's design, department has currentPlan and Plans. Besides, each plan has a department. Does this mean we will have a foreign key planID in table Department references to planID in table Plan in the database? However, we also have a foreign key departmentID in table Plan references to departmentID in table Department in the database. This is okay to create Tables but not to delete tables. Is there anything I misunderstand about the design? Thank you for your answers. Last edited by Yuan-Yu at
21:18 Feb 05, 2015.
|
cysun
Posts: 2935
|
Posted 22:24 Feb 05, 2015 |
It's not uncommon to have "circular" foreign key constraints in a database schema. To create the tables you just need to create the tables without the constraints first, then use ALTER TABLE ... ADD CONSTRAINT to add the constraints - see the DDL generated by Hibernate SchemaExport for examples. Similarly, to drop the tables you need to drop the constraints first using ALTER TABLE ... DROP CONSTRAINT, and then you can drop the table themselves. |