290 likes | 414 Views
Database Design . Week 10. Agenda – Week 10. Review Hybrid Review Primary Keys Table Instance Charts. Review. Entities are…. Attributes are…. Primary key is….. Foreign key is …… Information is accessed according to its structure, not its location Use keys to identify relationships.
E N D
Database Design Week 10
Agenda – Week 10 Review Hybrid Review Primary Keys Table Instance Charts
Review Entities are…. Attributes are…. Primary key is….. Foreign key is …… Information is accessed according to its structure, not its location Use keys to identify relationships
Review Solution to Hybrid Homework
Three Basic Types of Relationships • One to One (1:1) • One to Many (1:M) • Many to Many (M:M)
One to One Relationships 1:1 relationships exists when a single record in one table has 1 and only 1 corresponding record in another table, and vice versa
One to One Example Voter Ballot A voter can cast only one vote in an election. A ballot paper can belong to only one voter. So there will be a 1:1 relationship between a Voter and a Ballot Paper.
One to Many Relationships Most common 1:m or m:1 Relationship exists when a record can relate to 1 or more records in a second table but.. A record in the 2nd table can only relate to 1 record in the first table
One to Many Example Owner Vehicle A person can own more than one car. A car can only have one owner.
Many to Many Relationships M:M Relationship exists when a record in either table can relate to more than one record in the other table
Many to Many Example Student Professor A student can have more than one professor; the same professor can have many students
Resolving Many to Many Student Stud_Prof Professor M:M is not allowed We create a junction or joiner entity The name of the joiner entity is often a combination of the 2 entities
Exercise: ERD & Relationships • Draw an ERD for the puzzle • Describe the relationships using the following format
Exercise: ERD & Relationships • Describe the relationships in the curling bonspiel
Review Relationship Essentials • Need a primary key • Need a foreign key • A foreign key is a column in a table used to reference a primary key in another table. • Not all tables will require a foreign key • Primary key and foreign keys are essential when you create relationships that join together multiple tables in a database
Common Data Types in Access Autonumber Text Memo Number Currency Date/Time Yes/No
Autonumber Use for unique sequential numbering Commonly used for PK Increments by 1 Automatically inserted when a record is added.
Text Used for text or combinations of text and numbers, such as addresses, or for numbers that do not require calculations, such as phone numbers, part numbers, or postal codes. Stores up to 255 characters.
Memo Use for lengthy text and numbers, such as notes or descriptions. Should be used sparingly Stores up to 65,536 characters (if not more)
Number Use for data to be included in mathematical calculations, except calculations involving money (use Currency type).
Yes/No • Use for data that can be only one of two possible values, such as • Yes/No, • True/False, • On/Off. • Null values are not allowed
Table Instance Chart Sample • One chart completed for each table • Wk10_TableInstanceChart.xlsx
Exercise • Create table instance chart for: • the puzzle (together)
Exercise • Create table instance chart for: • Curling Bonspiel scenario
Hybrid / Homework • Hybrid: Refer to the 14 Week schedule • Database Assignment Part 1