1 / 92

Concepts of Database Management Seventh Edition

Concepts of Database Management Seventh Edition. Chapter 6 Database Design 2: Design Method. Objectives. Discuss the general process and goals of database design Define user views and explain their function Define Database Design Language (DBDL) and use it to document database designs

caraf
Download Presentation

Concepts of Database Management Seventh Edition

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. Concepts of Database ManagementSeventh Edition Chapter 6 Database Design 2: Design Method

  2. Objectives • Discuss the general process and goals of database design • Define user views and explain their function • Define Database Design Language (DBDL) and use it to document database designs • Create an entity-relationship (E-R) diagram to visually represent a database design • Present a method for database design at the information level and view examples illustrating this method

  3. Objectives (continued) • Explain the physical-level design process • Discuss top-down and bottom-up approaches to database design and examine the advantages and disadvantages of both methods • Use a survey form to obtain information from users prior to beginning the database design process • Review existing documents to obtain information prior to beginning the database design

  4. Objectives (continued) • Discuss special issues related to implementing one-to-one relationships and many-to-many relationships involving more than two entities • Discuss entity subtypes and their relationships to nulls • Learn how to avoid potential problems when merging third normal form relations • Examine the entity-relationship model for representing and designing databases

  5. Introduction • Two-step process for database design • Information-level design: completed independently of any particular DBMS • Physical-level design: information-level design adapted for the specific DBMS that will be used • Must consider characteristics of the particular DBMS

  6. User Views • User view:set of requirements necessary to support operations of a particular database user (e.g. cashier, sales manager, accountant etc) • Ex. Premier products database should be capable of storing each part’s number, description, units on hand, item class, Warehouse number where the parts is located, price etc. • Cumulative design:supports all user views encountered during design process • Each user view is generally simpler than the total collections of requirements • Working on individual user view is more manageable therefore.

  7. Information-Level Design Method • For each user view: • Represent the user view as a collection of tables • Normalize these tables • Identify all keys in these tables • Merge the result of Steps 1 through 3 into the cumulative design Mnemonics : RaNK Me

  8. Represent the User View As a Collection of Tables • Step 1: Determine the entities involved and create a separate table for each type of entity • Step 2: Determine the primary key for each table • Step 3: Determine the properties for each entity • Step 4: Determine relationships between the entities • One-to-many • Many-to-many • One-to-one

  9. Represent the User View As a Collection of Tables (continued) • One-to-many relationship: include primary key of the “one” table as a foreign key in the “many” table • Many-to-many relationship: create a new table whose primary key is the combination of the primary keys of the original tables • One-to-one relationship: simplest implementation is to treat it as a one-to-many relationship

  10. Example User View • Departments and Employees • Each department can hire manyemployees and each employee work only in onedepartment.

  11. Represent the User View As a Collection of Tables - Step 1: Determine the entities involved and create a separate table for each entity What are the entities involved? Department Employee So, represent each entity as Table as shown below: Department ( Employee (

  12. Represent the User View As a Collection of Tables - Step 2: Determine the primary key for each table What does it take identify each entity uniquely? For Department entity probably Department Number Department (DepartmentNum, For Employee entity probably Employee Number Employee (EmployeeNum,

  13. Represent the User View As a Collection of Tables - Step 3: Determine the properties for each entity For Department entity, properties/fields could be: Department (DepartmentNum, Name, Location) For Employee entity, properties/fields could be: Employee (EmployeeNum, LastName, FirstName, Street, City, State, Zip, WageRate, SocSecNum)

  14. Represent the User View As a Collection of Tables - Step 4: Determine relationship between entities: Determine if it is One-to-One, One-to-Many or Many-to-Many Based on user requirements a Department could have many Employees but an Employee could only work in one Department. 1 M Department Employee One-to-Many

  15. Represent the User View As a Collection of Tables - Step 4: Determine relationship between entities: Remember the many side has the Foreign key? Which is the Primary Key of the one side. 1 M Department Employee Department (DepartmentNum, Name, Location) Employee (EmployeeNum, LastName, FirstName, Street, City, State, Zip, WageRate, SocSecNum, DepartmentNum) Primary Key Foreign Key

  16. Represent the User View As a Collection of Tables - Step 4: Determine relationship between entities: What if Many-to-many relationship? M N Department Employee Create a bridge Table between entities thus creating twoone-to-many relationship. Department (DepartmentNum, Name, Location) Employee (EmployeeNum, LastName, FirstName, Street, City, State, Zip, WageRate, SocSecNum) Bridge Table WorksIn (EmployeeNum, DepartmentNum)

  17. Graded Seatwork • See Page 224 on Textbook – Question No. 6 • Many employees can work on a given project but each employee can work only on a single project. • An Employee can work on many projects but each project has a unique employee assigned to it. • An employee can work on many projects and a project can be worked on many employees Note : Answer each letter above separately

  18. Normalize the Tables • Normalize each table • Target is third normal form • Careful planning in early phases of the process usually rules out need to consider fourth normal form

  19. Identify All Keys • For each table, identify: • Primary key • Alternate keys • Secondary keys • Foreign keys • Alternate key: column(s) that could have been chosen as a primary key but was not (e.g. SSN could be an alternate key if an EmployeeID is used instead of it) • Secondary keys:columns of interest strictly for retrieval purposes (e.g. Last Name, First Name instead of ID Number)

  20. Identify All Keys (continued) • Foreign key: column(s) in one table that is required to match value of the primary key for some row in another table or is required to be null • Used to create relationships between tables • Used to enforce certain types of integrity constraints

  21. Types of Primary Keys • Natural key:consists of a column that uniquely identifies an entity (e.g. Social Security Number, a book’s ISBN [International Standard Book Number], a product’s UPC [Universal Product Code] or a vehicle’s VIN [Vehicle Identification Number] • Also called a logical key or an intelligent key • Artificial key: column created for an entity to serve solely as the primary key and that is visible to users • Surrogate key: system-generated; usually hidden from users • Also called a synthetic key

  22. Database Design Language (DBDL) • Table name followed by columns in parentheses • Primary key column(s) underlined • AK identifies alternate keys • SK identifies secondary keys • FK identifies foreign keys • Foreign keys followed by an arrow pointing to the table identified by the foreign key

  23. Database Design Language (DBDL) (continued) FIGURE 6-1: DBDL for the Employee table

  24. Entity-Relationship (E-R) Diagrams • Visually represents database structure or the conceptual model of the Database

  25. Building Blocks of ERD

  26. ERD Popular Notation • Chen Notation • Crow’s Foot Notation

  27. Chen Notation - Symbol Rectangle represents an Entity Diamond represents a Relationship 1 M Lines with labels represents Cardinality

  28. Entity (Chen Notation) • is a real-world object distinguishable or unique from other objects. • An entity can be a concrete or physical object like employee, student, faculty, customer etc. Or it could also be conceptual or abstract like transaction, order, course, subjects etc. • It can be thought of as a noun like student, employee etc. • It is normally represented by a rectangle shape.

  29. Database Background Person (ex. Teacher, Student, Physician) • Remember in Chapter 1 Entity could be a : Place (ex. School, Hotel, Store ) Object (ex. Mouse, Books, Bulding ) Event (ex. Enroll, Withdraw, Order ) Idea or Concept (ex. Courses, Account, Delivery )

  30. Entity - Example • For example in our Premiere Database the different Entities are the following: Customer Sales Rep Order Parts

  31. Relationship • is a way of relating one entity to another. Entities can therefore participate in a relationship. • it is commonly thought as a verb connecting the entities or nouns. • It is normally represented by a diamond shape.

  32. Relationship - Example • For example in our Premiere Database again we have this relationships among entities: represents Customer Sales Rep has Could be read as : A Sales Rep Represents a Customer. And a Customer has an Order. Order

  33. Cardinality • Cardinality: number of items that must be included in a relationship • An entity in a relationship with minimum cardinality of zero plays an optional role in the relationship • An entity with a minimum cardinality of one plays a mandatory role in the relationship

  34. Cardinality - Symbols 1 M One-is-to-many Relationship M N Many-to-many Relationship

  35. Cardinality Symbols - Example represents Sales Rep 1 M Customer Could be read as : A Sales Rep could represent 1 or Many Customers.

  36. Cardinality Symbols – Example (Cont’d) has Order M N Parts Could be read as : An Order could have many Parts (e.g. Products Ordered) and a Part could have many Orders.

  37. Degree of Relationship • There are three Degree of Relationships in ERD notation, namely: • Unary • Binary • Ternary

  38. Degree of Relationship (Cont’d) Unary Binary Ternary

  39. Degree of Relationship (Cont’d) Manages Unary Employee makes Customer Orders Binary Vendor Warehouse Ternary supplies Part

  40. Attribute • Refers to the characteristic or basic fact or field of an Entity or Relationship. • For example a Student entity could have the following attributes ID Number, Last Name, First Name, Address, Birth Date etc. • A relationship could also have an attribute for example an Entity name Student enrolls (relationship) to a Course/Program. Now, when you enroll you enroll on a certain date so you will have an attribute of Enrollment Date under Enroll relationship. • It is normally represented by an oval.

  41. Attribute - Example Lastname Firstname RepNum Street City Sales Rep State Take note that a Primary Key is underlined. Rate Zip Commission

  42. Attribute – More Example CustomerName CustomerNum Lastname Firstname RepNum Street Street represents 1 M City City Sales Rep Customer State State Rate CreditLimit Zip Zip Commission Balance

  43. Crow’s Foot notation - Symbol Entity name Attribute 1 Attribute 2 Attribute 3 Attribute 4

  44. Crow’s Foot notation - Example Entity Student StudentID Firstname Lastname Gender Program Attributes

  45. Crow’s Foot notation - Keys Student PK – Primary Key StudentID (PK) Firstname (SK) Lastname (SK) Gender ProgramID (FK) SK – Secondary Key FK – Foreign Key

  46. Crow’s Foot Cardinality - Symbols One and only one included in the relationship Zero or many could be included in the relationship. This is optional mode. One or many could be included in the relationship. This is mandatory mode.

  47. Crow’s Foot notation – with Cardinality Customer Rep Customernum(PK) Customername Street City State Zip Balance CreditLimit Repnum (FK) Repnum (PK) Firstname Lastname CommissionRate

  48. ERD for Department/Employee example Customer Department EmployeeNum(PK) Lastname (SK) Firstname (SK) Street City State Zip WageRate SocSecNum (AK) DepartmentNum (FK) DepartmentNum(PK) Name Location

  49. Graded Seatwork • Make an ERD using both Chen and Crow’s Foot notation for Question No. 6 letter c onPage 224 of your Textbook – • An employee can work on many projects and a project can be worked on many employees

  50. Merge the Result into the Design • Combine tables that have the same primary key to form a new table • New table: • Primary key is same as the primary key in the tables combined • Contains all the columns from the tables combined • If duplicate columns, remove all but one copy of the column • Make sure new design is in third normal form

More Related