1 / 22

Relationships

Relationships. Today you are Learning. Understand the need for a relational database structure Be able to create ERDs of the relationship Use software to model and create a relational database. 10/03/2014. R.D.B.M.S - Entities.

Télécharger la présentation

Relationships

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Relationships

  2. Today you are Learning • Understand the need for a relational database structure • Be able to create ERDs of the relationship • Use software to model and create a relational database 10/03/2014

  3. R.D.B.M.S - Entities • A relational database consists of multiple tables joined (linked) together by relationships • Each table should contain data about a singleentity • Person – Employee • Object - Book • Event - Project

  4. R.D.B.M.S - Attributes • Attributes describe the properties of an entity • It’s easiest to think of attributes as fields

  5. Relationships

  6. ERDs Entity relationship diagram

  7. Relationships • One to one 1:1 • One to many 1:M • Many to Many M:M

  8. Relationships • One to one 1:1 • Teacher - classrooms • One to many 1:M • Teacher - courses • Many to Many M:M • Teachers - Students

  9. Relationship?

  10. Money

  11. Relationships.....

  12. Relationships.....

  13. Draw the relationship shown below • One to one 1:1 • Teacher - classrooms • One to many 1:M • Teacher - courses • Many to Many M:M • Teachers - Students

  14. Worked Example 1 • Look at the iTunes database on the next slide • Draw an ERD of the entities you would expect to see if this was converted into a relational databaseHINT: There are 4 entities. All relationships are one-to-many

  15. Worked Example 2

  16. Worked Example 3 • Did you get something like this? Artists Album Name Track Name Genres

  17. Creating a relationship • Load up the Actors database from the Cambridge Tech website • Create a ‘Oscars’ Table to join the data

  18. ENFORCE REFERENTIAL INTEGRITY • An enforced relationship ensures each value entered in a foreign key column matches an existing value in the related primary key column.

  19. Cascade Update Fields • cascading updates only update existing records so that if you were to make a change to the customers table, all instances of the customer id would be changed in the customer orders table.

More Related