WEEK 10 Database Design. Agenda – Week 10 Review Hybrid Review Table Instance Charts Primary Keys...
-
Upload
magdalen-stewart -
Category
Documents
-
view
221 -
download
2
Transcript of WEEK 10 Database Design. Agenda – Week 10 Review Hybrid Review Table Instance Charts Primary Keys...
Database Design Steps Review
Determine the purpose of the database
Determine the entitiesDetermine the fields & keysDetermine the relationshipsRefine the design
This is an iterative process that is completed several times
ReviewEntities are….Attributes are….Primary key is…..Foreign key is ……
Information is accessed according to its structure, not its location
Use keys to identify relationships
Planning the DesignERD –
◦Serves as a blueprint for implementation
◦Reduces problems resulting from poor design
◦Determines how data is stored◦Ensures that the design meets the
user’s needs
Table Instance Chart Sample One chart completed for each
table
◦Wk10_TableInstanceChart.xlsx
AutonumberUse for unique sequential
numberingCommonly used for PKIncrements by 1Automatically inserted when a
record is added.
TextUsed 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.
MemoUse for lengthy text and
numbers, such as notes or descriptions.
Should be used sparingly
Stores up to 65,536 characters (if not more)
NumberUse for data to be included in
mathematical calculations, except calculations involving money (use Currency type).
Yes/NoUse for data that can be only one
of two possible values, such as ◦Yes/No, ◦True/False, ◦On/Off.
Null values are not allowed
Three Basic Types of RelationshipsOne to One (1:1)
One to Many (1:M)
Many to Many (M:M)
Called the cardinality of the relationship◦The cardinality indicates the maximum
number of relationships between the entities, therefore "many" can be explained as "one or many" or sometimes "zero, one, or many".
One to One Relationships1: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 ExampleA 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.
Voter Ballot
One to Many RelationshipsMost 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
Many to Many RelationshipsM:M
Relationship exists when a record in either table can relate to more than one record in the other table
Many to Many ExampleA student can have more than
one professor; the same professor can have many students
Student Professor
Resolving Many to ManyM:M is not allowedWe create a junction or joiner
entityThe name of the joiner entity is
often a combination of the 2 entities
Student ProfessorStud_Prof
Normalization Refining the ERD
Task of analyzing entities and the relationships created have been formalized into a process called normalization.
Exercise: ERD & Relationships
Draw an ERD for the puzzle◦Describe the relationships using the
following formatSource Entity
Destination Table
Relationship Type
Describe the relationship in your own words
Customer Movie Rental
Movie Rental
customer
Movie Movie Rental
Movie Rental
Movie
Exercise: ERD & Relationships
Draw an ERD for the wine scenario◦Describe the relationships using the
following format
◦Describe the relationships in the curling bonspiel
Source Entity
Destination Table
Relationship Type
Describe the relationship in your own words
Review Relationship EssentialsNeed 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
Build TimeFor each of the following
scenarios:◦Create and write out a business
narrative ◦Create list of tables◦Create the attributes for the table◦Create a simple ERD and the
relationship rules◦Create a table instance chart
ScenariosPolitical CanvassingHuman Resource Dept.Private Elementary SchoolYoga Studio
*** note each database should be around 5 tables