Database Design Sections 11 & 12 drawing conventions, generic model, integrity, keys, mapping conceptual model to logical/physical model.

Slides:



Advertisements
Similar presentations
Database Systems: Design, Implementation, and Management Tenth Edition
Advertisements

The Relational Database Model – some relations you might want to avoid!!!
The Relational Database Model
Chapter 6 Methodology Logical Database Design for the Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 8.
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
Relational Model Stores data as tables –Each column contains values about the same attribute –Each column has a distinct name –Each row contains values.
The Relational Database Model:
Methodology Logical Database Design for the Relational Model
Concepts of Database Management Seventh Edition
CS424 PK, FK, FD Normalization Primary and Foreign Keys Primary and foreign keys are the most basic components on which relational theory is based. Primary.
Modeling & Designing the Database
Transforming Data Models into Database Designs
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Using ER/Studio.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
Oracle Academy -Week 1-.
The Relational Database Model
Chapter 3 Relational Model Chapter 4 in Textbook.
CSC271 Database Systems Lecture # 6. Summary: Previous Lecture  Relational model terminology  Mathematical relations  Database relations  Properties.
Chapter 4 The Relational Model.
1 Introduction to modeling Relational modelling Slides for this part are based on Chapters 11 from Halpin, T. & Morgan, T. 2008, Information Modeling and.
DATA MODELING AND DATABASE DESIGN
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Database Design Sections 6 & 7 Second Normal Form (2NF), Unique Identifiers (UID), Third Normal Form (3NF), Arcs, Hierarchies and Recursive relationships.
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Concepts and Terminology Introduction to Database.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Database Design Sections 9 & 10 Modeling Historical Data, conditional nontranferability, time-related constraints, Database conventions, generic modeling.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Database Design Sections 9 & 10 Modeling Historical Data, conditional nontranferability, time-related constraints 1.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
CSCI 3140 Module 3 – Logical Database Design for the Relational Model Theodore Chiasson Dalhousie University.
Concepts of Database Management Eighth Edition Chapter 6 Database Design 2: Design Method.
Concepts of Database Management Sixth Edition Chapter 6 Database Design 2: Design Method.
C-1 Management Information Systems for the Information Age Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Extended Learning Module.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Database Design Sections 11 Database relationship, Integrity, keys, mapping conceptual model to logical/physical model Previous Section 12 – DDLesson11Fa12.ppt.
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
Subtype Mapping. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –State and apply the table, column, identifiers,
Information Access Mgt09/12/971 Entity-Relationship Design Information Level Design.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Logical Database Design and the Relational Model.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 2.
Lecture 4: Logical Database Design and the Relational Model 1.
Methodology - Logical Database Design. 2 Step 2 Build and Validate Local Logical Data Model To build a local logical data model from a local conceptual.
Week 2 Lecture The Relational Database Model Samuel ConnSamuel Conn, Faculty Suggestions for using the Lecture Slides.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
1 Database Design Sections 6 & 7 First Normal Form (1NF), Second Normal Form (2NF), Unique Identifiers (UID), Third Normal Form (3NF), Arcs, Hierarchies.
CSIS 115 Database Design and Applications for Business
Logical Database Design and the Rational Model
Chapter 5 Database Design
Methodology Logical Database Design for the Relational Model
Chapter 4 Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
Tables and Their Characteristics
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
CIS 207 The Relational Database Model
Developing Data Models – Conversion Rules
Data Modelling Introduction
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Design: Relational Model
Presentation transcript:

Database Design Sections 11 & 12 drawing conventions, generic model, integrity, keys, mapping conceptual model to logical/physical model

Marge Hohly2 Conventions Review  Crows feet Crows fly East and South Divide complex ERD’s into functional areas Place Highest volume entities in upper left corner Improve readability  avoid criss-crossing lines  increase white spaces so relationships don’t overlap  be consistent with font type, size, and styles

Marge Hohly3 Generic Modeling  Can reduce number of entities in diagram  Can provide more flexibility in unstable situations (where business requirements change often)  Use a more distant perspective  Review  What would happen to the generic model if we had to add 10 new ARTICLE types, each with their own attributes?

Marge Hohly4 Generic Modeling  Have more attributes in fewer entities  Many mandatory requirements/attributes become optional  Structural rules become procedural rules  Example: PANTS waist size was mandatory, with ARTICLE waist size becomes optional  What other businesses would be good candidates for generic modeling?

Marge Hohly5 Relational Database Concepts  Conceptual model transforms into a relational database  A relational database is a database that is perceived by the user as a collection of relations or two- dimensional tables.  Table, each employee (instances), and each column (attribute)

Marge Hohly6 SQL to retrieve information  Structured query language (SQL) used to access information  English-like phrases  Example: SELECT lname, dept_no FROM employees WHERE emp_no = 210;

Marge Hohly7 Using HTML_DB SQL editor HTML_DB SQL Editor

Marge Hohly8 Table Definitions Table – Dfn.

Marge Hohly9 Employee Table Structure

Marge Hohly10 Selecting all records  SELECT * FROM employees WHERE department_no = 10;

Marge Hohly11 Keys  Primary Key (PK) not null no part of PK can be null (entity integrity) unique can be composite  Foreign Key (FK) depends on business rule comes from relationship primary key from another table If FK is part of a PK, then the FK can’t be NULL

Marge Hohly12 Key questions  what makes emp_no and payroll_id good candidates for the primary key?  why is having alternate or unique keys useful?

Marge Hohly13 Referential Integrity  Use Foreign Key to map relationships  A foreign key (FK) is a column or combination of columns in one table that refers to a primary key in the same table or another table.  (next slide)

Marge Hohly

Marge Hohly15 Composite key  Made up of two or more values  Together unique  ENROLL Table/Entity student_no & ticket_no  ACCOUNTS bank_no & acct_no

Marge Hohly16 JOBS Table

Marge Hohly17 Data-Integrity Summary  Entity integrity- no part of PK can be NULL  Referential integrity – FK must match an existing PK value (or else be NULL)  Column integrity – column must contain only values consistent with defined data format  User-defined integrity – data stored in database must comply with the rules of the business

Marge Hohly18 Transformation  Conceptual model, focus on the business and its rules.  Data modeling pays attention to the business requirements, regardless of implementation.  Conceptual model Logical model

Marge Hohly19 Review

Marge Hohly20 Conceptual becomes Physical model  Conceptional becomes Physical model

Marge Hohly21 Terminology Mapping  - An entity leads to a table.  - An attribute becomes a column.  - A primary unique identifier produces a primary key.  - A secondary unique identifier produces a unique Key.  - A relationship is transformed into a foreign key and foreign-key columns.  - Constraints are the rules that the database must follow to be consistent. Some of the business rules are translated into check constraints; other more complex ones require additional programming in the database or the application.

Marge Hohly  For entity names of more than one word, take the:  - First character of the first word  - First character of the second word  - Last character of the last word  Example: JOB ASSIGNMENT gets a short name of JAT  For entity names of one word but more than one syllable, take the:  - First characer of the first syllable  - First character of the second syllable  - Last character of the last syllable  Example: EMPLOYEE gets a short name of EPE  For entity names of one syllable but more than one character:  - First character  - Second character  - Last character  Example: FLIGHT gets a short name of FLT

Marge Hohly23 Naming restrictions with Oracle  Table and column names: must start with a letter can contain up to 30 alphanumeric characters cannot contain space or special characters such as “!,” but “$,” “#,” and “-“ are permitted  Table names must be unique. Column names must be unique within a table. Avoid “reserved” words in tables and columns.

Marge Hohly24 Cascade barred relationships  UID from parent entity becomes part of the UID of the child entity

Marge Hohly25 Relationship mapping  Relationships are mapped to foreign keys  Foreign keys enable users to access related information from other tables.  Mapping relationships to relational database structures is part of creating the “first-cut” database design.

Marge Hohly26 Relationship mapping  1:M mapping  Foreign key goes in table at crow’s foot from parent  FK1 Dept_id mandatory is required  FK2 might be better mgn_id and is optional  Does the president of the company have a manager?

Marge Hohly27 Relationship mapping  FK is mandatory from this diagram  FK is optional from this diagram

Marge Hohly  Optional or Mandatory determined by crow’s foot end of relationship

Marge Hohly29 NonTransferable Relationship  Transferablility is a procedural model  Must be implemented by a program  Need to document this constraint/business rule

Marge Hohly30 Barred Relationship   Barred relationship is mapped to a foreign-key column on the many side, just like any other M:1 relationship.  Bar means it becomes part of the composite primary key of the child  ACCOUNT table has both acct_id and bank_id as the composite primary key

Marge Hohly31 Cascading barred relationships  Pick up one more component to the composite key with each level  Company – company_id  Division company_id & div_id  Department company_id, div_id & dept_no  Team team_id, company_id, div_id & dept_no TEAM DEPARTMENT DIVISION COMPANY within made up of

Marge Hohly32 M:M relationship mapping  M:M resolved with intersection entity  Intersection entity has a composite key with the PK from each parent as FK in child

Marge Hohly33 1:1 relationship mapping  Create a foreign key and a unique key  If relationship mandatory on one side, Foreign key created on the mandatory side as a unique key  If optional on both sides, you can choose which table gets the foreign key.

Marge Hohly34 Review  FK 1:M  PK, FK in same key, rename one  M:M first resolve with an intersection entity * o

Marge Hohly35 Review cont.  Will be part of PK a composite key  FK on mandatory side  FK on either side

Marge Hohly36 Arc mapping  Foreign key from the parent (single) side are placed in the child (many) side  The Foreign key is ALWAYS Optional in the child  Only of the Arc can be valid and all others must be NULL  Mandatory relationship is enforced with a check constraint

Marge Hohly37 Arc constraint  You need a constraint to make sure only one is NOT NULL at a time  Example: FK1, FK2, FK3,....  ALTER EVENT constraint (FK1 is not null and FK2 is null and FK3 is null....) OR (FK1 is null and FK2 is not null and FK3 is null....) OR (FK1 is null and FK2 is null and FK3 is not null....)

Marge Hohly38 ARC mapping  If mandatory then one MUST be NOT NULL  If optional then all may be NOT NULL  You will always need a check constraint defined

Marge Hohly39 Subtype Review

Marge Hohly40 Subtype mapping  Mapping supertypes and subtypes makes sure that the right information gets stored with each type.

Marge Hohly41 Subtype modeling  Mapping as a single table  Rules Tables: Only one table is created, independent of the number of subtypes. Columns: The single table gets a column for all the attributes of the supertype, with the original optionality.  Table gets a column for each attribute of the subtype, but column are.  Mandatory column to distinguish between each different subtypes of entity.

Marge Hohly42 Subtype modeling – Single table cont.  Rules Identifiers: Unique identifiers transform into primary and unique keys. Relationships: Relationships at the supertype level transform as usual. Relationships at subtype level are implemented as optional foreign-key columns. Integrity constraints: A check constraint is needed to ensure that for each particular subtype, all columns that come from mandatory attributes are not null.

Marge Hohly43 Subtype model – Single table  Note mandatory attributes salary/hourly rate became optional  Need check constraint to enforce mandatory requirement CHECK (epe_type = ‘FTE’ and salary is not null and hourly_rate is null and agy_id is null) OR (epe_type ‘PTE’ and salary is null and hourly_rate is not null and agy_id is not null)

Marge Hohly44 When Supertype/Single table  The single-table implementation is common and flexible implementation.  Appropriate where: Most attributes are at supertype level Most relationships are at supertype level Business rules are globally the same for the subtypes

Marge Hohly45 Two-Table implementation  Create a table for each subtype  Rules Tables: One table per first-level subtype. Columns: Each table gets a column for all attributes of the supertype with the original optionality. Each table also gets a column for each attribute belonging to the subtype, also with the original optionality. Identifiers: The primary UID at the supertype level creates a primary key for each table. Secondary UIDs of the supertype become unique keys in each table. Relationships: All tables get a foreign key for a relationship at the supertype level, with the original optionality. For relationships at the subtype levels, the foreign key is implemented in the table it is mapped to. Original optionality is retained.

Marge Hohly46 2-table cont.  A separate table would be created for SHIRTS and SHOES.

Marge Hohly47 Subtype Considerations  Subtype implementation may be appropriate when: Subtypes have very little in common. There are few attributes at the supertype level and several at the subtype level. Most of the relationships are at the subtype level. Business rules and functionality are quite different between subtypes. How tables are used is different -- for example, one table is being queried while the other is being updated.