Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save philsof/aa685ab5e968703c161b to your computer and use it in GitHub Desktop.
Save philsof/aa685ab5e968703c161b to your computer and use it in GitHub Desktop.
code-review-for-pair-edwardgemson-university-course-database-design-challenge

Good effort! Ok there are a bunch of issues with your schema. It looks like you got confused when implementing the sections. Take a look at your relationships, and remember: the "one" side of a relationship is the side that has the id primary key, and the "many" side is the side that has the foreign key (which is always [name-of-other-table]_id)

So right now, these are your assocations: ###Good associations:###

  • a student can have many classes, and a class can have many students [GOOD; this is the red line and black line attached to the students_classes table]
  • one class can have many sections, and a section can have only one class [GOOD; this is the black line attached to the sections table]
  • a teacher can have many sections, and a section can have only one teacher [GOOD; this is the dark blue line]

###Half good, half not good association:###

  • a section can have many students, but a student can have only one section [FIRST PART GOOD, SECOND PART NOT GOOD; this is the turquoise line connecting sections and students]

###Not good associations:###

  • one class can have many departments, and a department can have only one class [NOT GOOD; this is the black line attached to the department table]
  • a section can have many teachers, and a teacher can have only one section [NOT GOOD; this is the turquoise line connecting teachers and sections]

You should redo this. Before you go to the schema designer, write down the associations that you want, like you see above. Then remember these simple rules:

  • One-to-many: the one side is id, the many side is table_id as an additional foreign key. In your current schema, an example of one-to-many is your classes to department relationship, which is currently "one class can have many departments, but a department can have only one class" (which you need to reverse!).
  • Many-to-many requires a join table, exactly like your current students_classes table
  • One-to-one dont' worry about for now (also don't worry about the time constraints for now)

Talk to me if you want more info on this. I am here to help.

(Also FYI: Always save the XML code of your schema designs, so you can edit them in the future if needed.)

-Phil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment