IT203 Unit 3: Database Design

Slides:



Advertisements
Similar presentations
Entity Relationship (ER) Modeling
Advertisements

Entity Relationship (E-R) Modeling
1 Senn, Information Technology, 3 rd Edition © 2004 Pearson Prentice Hall James A. Senns Information Technology, 3 rd Edition Chapter 7 Enterprise Databases.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to XHTML Programming the World Wide Web Fourth edition.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 3 CPUs.
Database Design DB Chapter 5 J.G. Zheng June 29th 2005.
IT203 Unit 9: Database Security II Is It Secure? Copyright © 2012 Pearson Education, Inc. Publishing as Prentice HallChapter8.1.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Conceptual / semantic modelling
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Week 2 The Object-Oriented Approach to Requirements
Information Systems Today: Managing in the Digital World
Database Design Process
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Excel 2010 by Robert Grauer, Keith.
© Paradigm Publishing, Inc Access 2010 Level 1 Unit 1Creating Tables and Queries Chapter 2Creating Relationships between Tables.
Chapter 4 Database Design Chapter4.1 Copyright © 2014 Pearson Education Inc.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Database Design Chapter Five DATABASE CONCEPTS, 6th Edition
Microsoft Access.
Chapter Information Systems Database Management.
Chapter 6 Data Design.
Access Tables 1. Creating a Table Design View Define each field and its properties Data Sheet View Essentially spreadsheet Enter fields You must go to.
Use Case Diagrams.
Managing Projects Chapter 14.
VOORBLAD.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
© 2012 National Heart Foundation of Australia. Slide 2.
Chapter 6: ER – Entity Relationship Diagram
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Skills for Success with Microsoft® Office 2010
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
25 seconds left…...
Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques
 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall Chapter 10 The Tools of Quality.
Chapter Ten Marketing Communications and Customer Response.
Speak Up for Safety Dr. Susan Strauss Harassment & Bullying Consultant November 9, 2012.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 12 View Design and Integration.
Essential Cell Biology
Intracellular Compartments and Transport
PSSA Preparation.
Statistically-Based Quality Improvement
Chapter 11 Describing Process Specifications and Structured Decisions
Essential Cell Biology
Retail Organization and Human Resource Management
1 Chapter 13 Nuclear Magnetic Resonance Spectroscopy.
 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall Chapter 14 Managing Quality Improvement Teams and Projects.
Financial Merchandise Management
© Copyright 2011 John Wiley & Sons, Inc.
Data Modeling and the Entity-Relationship Model
Database Design Chapter Five DATABASE CONCEPTS, 6th Edition
Entity-Relationship Model
Using Dataflow Diagrams
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 7.1.
Entity-Relationship Model
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 7.1.
Chapter 9 Designing Databases Modern Systems Analysis and Design Sixth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
1 Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall. Access Module 1 Workshop 2 Tables, Keys, and Relationships Series Editor Amy Kinser.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Five: Data Modeling with the Entity-Relationship.
Presentation transcript:

IT203 Unit 3: Database Design Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Logical Design Logical design is the entity design without regard to a Relational Database Management System. One of the principles of relational databases is that the logical design should be the same regardless of the DBMS that will be used. This means you don’t consider the particular limitations or features of a DBMS in the design. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Physical Design Physical design is the logical design adapted to a particular DBMS. The design can change slightly to fit into the limitations of a DBMS or to take advantage of DBMS-specific features. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Entity Relation Diagrams Entity Relation Diagrams (ERDs) are a common way of diagramming entities, their attributes, and their relationships. An entity is represented as a rectangle divided into three parts: The name of the entity The primary key The attributes Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall An Entity Attributes in bold are required. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Relationships A relationship between entities is established by repeating one field, usually the primary key field, from one table in a another table, usually as a foreign key. The primary key table is sometimes referred to as the “parent” table. Tables with the foreign keys are referred to as “child” tables. There are different ways to depict relationships. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Arrow Headed Relationship Arrows are often used to depict relationships. The arrow’s head always points to the parent table, the primary key side of the relationship. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Crow’s Feet Notation for Relationships The three lines, the crow’s foot, show the “many” side of the relationship. The 0 on the building side says a building can have zero or many rooms; the line on the room side says a room must have a building. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Crow’s Feet Notation Crow’s feet notation is an alternative to the arrow notation. It is more complex, but conveys much more information about the relationship itself. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Naming Conventions Naming conventions are crucial for good design. Ideally you should have a consistent way of naming database objects such as tables, attributes, keys, and any other database objects such as stored procedures and triggers. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Book Naming Conventions Entities and tables are named as single nouns like Tutor, Student, and Session. Attributes are named with the entity name followed by the attribute name. There are no underscores between words. Each new word is capitalized: TutorLastName, StudentLastName, and so on. This can result in long attribute names, but it makes for maximum clarity. Primary keys end with the word “Key”: TutorKey, StudentKey, and so on. Foreign keys retain the name of the primary key. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Term Equivalencies Logical Design Physical design Theoretical Entity Table Relation Attribute Column, field   Row, Record Tuple Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Repeating Fields When creating an entity that can contain many of the same attributes, it is tempting to list or number them. For example, a tutor can tutor many classes. The temptation is to create an entity like this: Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Resolution Numbering attributes is always a mistake. It is a sign that you should split the entity into two separate entities. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Relationships There are three types of relationships between entities: One-to-one One-to-many Many-to-many Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall One-to-One A one-to-one relationship means that for every one record in the primary key table, there is no more than one related record in the foreign key table. Below are the crow’s feet notation for this relationship: Zero or one Exactly one Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Notes on One-to-One Relationships One-to-one relationships are rare. They can be used to rid an entity of null (empty) attributes that inevitably result when contents of an entity have different attributes. They are sometimes used when data is split between entities for security reasons. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

One-to-One Relationship to Prevent Nulls Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Table Example: One-to-One For Reducing Nulls Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

One-to-One for Security Reasons Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall One-to-Many One-to-many is the normal relationship between tables. It means that for every one record in the parent entity, there can be zero to infinity records in the child entity. Here are the crow’s feet symbols for one-to-many relationships: One to zero or many At least one or many Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall One-to-Many Diagram One department can contain many employees. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Table Example of One-to-Many DepartmentKey DepartmentName DepartmentPhone DepartmentRoom ACC Accounting (206)555-1234 SB201 IT Information Technology (206)555-2468 NB100 EmployeeKey EmployeeLastName EmployeeFirstName DepartmentKey FB2001D Collins Richard IT BN2004N Faulkner Leonore NC2004M Brown Carol ACC LL2006O Anderson Thomas Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Caution: Cross Relationship Error There is a temptation to think that because a department contains many employees, the relationship should go both ways. However, doing this makes it impossible to enter data since before you enter a department, there must be an existing employee in the Employee table, and before you enter an employee, there must be an existing department in the Department table. The result is an unusable stalemate. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Many-to-Many A many-to-many relationship means that each record in the primary entity can have many related records in a second entity and each record in the second entity can have many related records in the primary entity. Many-to-many relationships are legal in logical design, but no DBMS can implement them. Visio has no symbol for a many-to-many relationship, but it would be this: Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Example of a Many-to-Many Entity Relationship Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Resolving Many-to-Many Relationships Many-to-many relationships must be resolved into two one-to-many relationships. To do this, it is necessary to create a linking between the two tables that have many-to-many relationships. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Many-to-Many Relationship Resolved Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Table View: Magazine and Subscriber MagazineKey MagazineName MagazinePrice TM2K1 Time 35.50 NW2K1 Newsweek 36.40 SubscriberKey Subscriber LastName Subscriber FirstName Address City Subscriber State PostalCode 4231 Johnson Leslie 101 Best Ave. Seattle WA 98007 4333 Anderson Mark 1200 Western Blvd Tacoma 98011 5344 Manning Tabitha 100 Westlake 98008 Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Linking Table: Subscription SubscriptionKey MagazineKey SubscriberKey SubscriptionStartDate 1004 TM2K1 4333 1/15/2009 1005 NW2K1 1006 4231 2/1/2009 1007 5344 2/15/2009 Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Cardinality Cardinality describes the number of permissible relationships between two entities. Maximum cardinality refers to the maximum number of permitted relationships. (For example, a customer can have no more than 4 listed emails.) Minimum cardinality refers the minimum number of permitted relationships. (For example, each customer must have at least one purchase in the purchase table.) Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Types or Roles of Entities Entities can take on different roles. Here are some common roles or types: Entity Roles Description Domain Entity describing a core business element of the database Linking Entity used to resolve a many-to-many relationship into two one-to-many relationships Lookup Entity used to store lookup values and help ensure data integrity and consistency Weak An entity that depends on another entity for its meaning Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Example of a Weak Entity An employee can have many dependents, so it is a good design practice to create a separate entity to describe dependents. However, the dependent entity is a weak entity because it depends one employee for its meaning. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall Documentation Diagrams often communicate more clearly than words. It is important to keep all your entity diagrams for documentations along with notations about changes and versions. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall