Scenario : 2


Create the Following Tables with suitable Primary keys , Foregin keys and identify the order of tables ?


Dept Table                     : id, name
Course Table                 : id, name, dept, other_info
Teacher Table                : id, fname, lname, phone
Section Table                 : id, course, teacher_id, capacity
Student Table                : id, fname, lname, dob, phone
Student_section Table   :         id, studid, sectionid

Dept Table:
  • id (Primary Key)
  • name
Teacher Table:
  • id (Primary Key)
  • fname
  • lname
  • phone
Course Table:
  • id (Primary Key)
  • name
  • dept (Foreign Key referencing Dept Table)
  • other_info
Section Table:
  • id (Primary Key)
  • course (Foreign Key referencing Course Table)
  • teacher_id (Foreign Key referencing Teacher Table)
  • capacity
Student Table:
  • id (Primary Key)
  • fname
  • lname
  • dob
  • phone
Student_section Table:
  • id (Primary Key)
  • studid (Foreign Key referencing Student Table)
  • sectionid (Foreign Key referencing Section Table)
The order of the tables considers the dependencies between them:
  • Dept Table     :   No other table depends on it, so it comes first.
  • Teacher Table :   No other table depends on it.
  • Course Table   :   Depends on Dept Table as well as Teacher Table.
  • Section Table   :   Depends on Course Table and Teacher Table.
  • Student Table   :   No other table depends on it.
  • Student_section Table: Depends on both Student Table and Section Table. 

Comments

Popular posts from this blog

Installing MySQL and MySQL Workbench

Java Program to Check Palindrome Number

Scenario : 1