Concepts of Database Management, Fifth Edition Chapter 6: Database Design 2: Design Methodology
2 Concepts of Database Management, 5t h Edition Database Design u Information-level Design – building a database that satisfies the organization’s requirements as cleanly as possible u Physical-level design – designers transform the information-level design into a design for the specific DBMS used by the organization u User Views – requirements necessary to support a particular user’s operations u Cumulative design – supports all user views encountered so far in the design process
3 Concepts of Database Management, 5t h Edition Information-Level Design Methodology u Information-level Design Methodology l Represent user view as collection of tables l Normalize these tables l Identify all keys l Merge the result into design
4 Concepts of Database Management, 5t h Edition Represent User View as Collection of Tables Step 1: Determine entities involved and create separate table for each type Step 2: Determine primary key for each table Step 3: Determine properties for each entities Step 4: Determine relationships among entities
5 Concepts of Database Management, 5t h Edition Types of Relationships u One-to-Many Relationships – created by including the primary key of the “one” table as a foreign key in the “many” table u Many-to-Many Relationships – created with a new table whose primary key is the combination of the primary keys of the original tables u One-to-One Relationship – created with a single relationship from one record in a table to a single record in another table
6 Concepts of Database Management, 5t h Edition Normalize the Tables u Represent all keys l Primary, alternate, secondary, foreign u Database Design Language (DBDL) l Mechanism for representing tables and keys DBDL Example Figure 6.1
7 Concepts of Database Management, 5t h Edition Types of Primary Keys u Three types of primary keys used in database design 1. Natural key (logical key or intelligent key) – consists of a column that uniquely identifies an entity 2. Artificial key – column created for an entity to serve solely as the primary key; visible to users 3. Surrogate key (synthetic key) – system-generated primary key usually hidden from users
8 Concepts of Database Management, 5t h Edition DBDL Notation u Table name followed by columns in parentheses l Primary key column(s) underlined u AK identifies alternate keys u SK identifies secondary keys u FK identifies foreign keys
9 Concepts of Database Management, 5t h Edition Entity-Relationship Diagrams u Diagram that visually represents database structure l Rectangle represents each entity in the E-R diagram u Primary key for each entity appears above the line in the rectangle for each entry
10 Concepts of Database Management, 5t h Edition Entity-Relationship Diagrams u Other columns that comprise each entity appear below the line within each rectangle u The letters AK, SK, and FK appear in parentheses following the alternate key, secondary key, and foreign key respectively u For each foreign key, there is a line leading from the rectangle that corresponds to the table being identified to the rectangle that corresponds to the table containing the foreign key
11 Concepts of Database Management, 5t h Edition Figure 6.2: Entity-Relationship Diagrams
12 Concepts of Database Management, 5t h Edition Merge the Result into the Design u As soon as Steps 1 through 3 for a given user view have been completed, the results can be merged into the cumulative design l If the working view is the first user view, the cumulative design will be identical to the design for the first user l Otherwise, all the tables for this user with those that are currently in the cumulative design
13 Concepts of Database Management, 5t h Edition Merge the Result into the Design (con’t) u Next, you combine tables that have the same primary key to form a new table l New table has the same primary key as those tables you have combined l New table also contains all the columns from both tables l In the case of duplicate columns, you remove all but one copy of the column
14 Concepts of Database Management, 5t h Edition Figure 6.4: User View Examples View #1: Sales Rep View Rep (RepNum, LastName, FirstName, Street, City, State, Zip, Commission, Rate)
15 Concepts of Database Management, 5t h Edition View #2: Customer View Figure 6.5: User View Examples
16 Concepts of Database Management, 5t h Edition Entities u Independent entity - an entity that does not require a relationship to another entity for identification u Dependent entity - an entity that does require a relationship to another entity for identification