DATABASE LOGICAL DESIGN - I Chandra S. Amaravadi 1.

Slides:



Advertisements
Similar presentations
Chapter 5 Normalization of Database Tables
Advertisements

Functional Dependencies and Normalization for Relational Databases.
Monash University Week 7 Data Modelling Relational Database Theory IMS1907 Database Systems.
Systems Development Life Cycle
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Functional Dependencies CS 186, Spring 2006, Lecture 21 R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Chapter 4: Logical Database Design and the Relational Model (Part II)
Week 6 Lecture Normalization
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
DATABASE LOGICAL DESIGN -- II Chandra S. Amaravadi 1.
Concepts and Terminology Introduction to Database.
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
The Relational Model and Normalization R. Nakatsu.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Your name here. Improving Schemas and Normalization What are redundancies and anomalies? What are functional dependencies and how are they related to.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Functional Dependencies and Normalization for Relational Databases.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
BIS 360 – Lecture Eight Ch. 12: Database Design and Normalization.
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
© 2005 by Prentice Hall 1 The Database Development Process Dr. Emad M. Alsukhni The Database Development Process Dr. Emad M. Alsukhni Modern Database Management.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
WXGE 6101 DATABASE CONCEPTS & IMPLEMENTATIONS. Lesson Overview The Relational Model Terminology of relational model. Properties of database relations.
Functional Dependencies R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another. Thomas Hobbes ( )
Logical Database Design and the Relational Model.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part c): Logical Database Design and the Relational Model Modern Database Management.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
1 Class Agenda (04/06/2006 and 04/11/2006)  Discuss use of Visio for ERDs  Learn concepts and ERD notation for data generalization  Introduce concepts.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Logical Database Design and the Relational Model.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Normalization Hour1,2 Presented & Modified by Mahmoud Rafeek Alfarra.
IST Database Normalization Todd Bacastow IST 210.
Ch 7: Normalization-Part 1
Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer.
Chapter 5 MODULE 6: Normalization © 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Prepared by: KIM GASTHIN M. CALIMQUIM.
Lecture 4: Logical Database Design and the Relational Model 1.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
Normalization. Overview Earliest  formalized database design technique and at one time was the starting point for logical database design. Today  is.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
Logical Database Design and Relational Data Model Muhammad Nasir
Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Chapter 4: Logical Database Design and the Relational Model Modern Database Management.
Microsoft Access CS 110 Fall Entity Relationship Model Entities Entities Principal data object about which information is to be collectedPrincipal.
1 Database -- III (Database Design) By Chandra s. Amaravadi.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 4: PART C LOGICAL.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Logical Design & the Relational Model
Logical Database Design and the Rational Model
DATABASE LOGICAL DESIGN - I Chandra S. Amaravadi.
Chapter 5: Logical Database Design and the Relational Model
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Example Question–Is this relation Well Structured? Student
CMPE 226 Database Systems February 21 Class Meeting
Normalization.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database -- III (Database Design) By Chandra s. Amaravadi.
Database Normalisation
Review of Week 3 Relation Transforming ERD into Relations
Presentation transcript:

DATABASE LOGICAL DESIGN - I Chandra S. Amaravadi 1

2 WHAT IS DESIGN? Database design involves what?

3 DESIGN OBJECTIVES The objective of database design is to develop a set of well structured tables so that: Data is in the most efficient form No uncontrolled redundancies User needs satisfied Database can be easily implemented The output of design are a set of well structured/normalized tables.

ILL STRUCTURED TABLES EMPLOYEE 4 eidnametitledt. promoted 2356ArmstrongAnalyst4/14/ NickersonSr. Analyst5/1/11; 2/5/12 EXAMPLE OF Ill structured tables are problematic. why?

DESIGN CONCEPTS ANOMALY: Insertion Deletion Update An inconsistency in the database that results from either adding records, deleting them or updating them. Three types of anomalies: 5

DESIGN CONCEPTS.. INSERTION ANOMALY: An insertion anomaly occurs if when trying to add a record, it cannot be added without additional information or it may need to be added in multiple places instead of in one location. DELETION ANOMALY: A deletion anomaly occurs, if when we try to delete a record, we have to perform the deletion a number of times, or if we lose information we did not intend to lose. 6

DESIGN CONCEPTS.. UPDATE ANOMALY/MODIFICATION ANOMALY: An update anomaly occurs, if when we try to update a record, instead of making the update in one location, we need to update in multiple locations. Are anomalies common in the file processing approach? 7

EMPLOYEES ILLUSTRATION OF ANOMALIES 8 empIDname dept. salarycoursedt completed 100 Jeff Simpson Mktg.48KSPSS 6/19/ Jeff Simpson Mktg.48KSurvey6/19/ Alan Beeton Acctg.52KTax Acct12/08/ Chris Lucero IS43KSPSS1/22/ Chris Lucero IS43KC++ 4/22/ Lorenzo Davis Fin.55K 150 Susan Martin Mktg. 42KSPSS 6/19/ Susan Martin Mktg. 42KJava 8/12/14

ANOMALIES.. 1. Insert Tom White, ID 130, Finance, 60K 2. Delete Employee with ID Employee with ID 100 gets a 10% salary increase 9

10 WELL STRUCTURED TABLE 10 no repeating groups redundancies minimized anomalies minimized all attributes dependent on pkey full functional dependency A Well structured table may be defined in a number of ways:

METHODS OF DESIGN ER diagrams (using thumb rules) Normalization theory FD approach brute force 11 Design can be carried out with:

DESIGN FROM ER CHARTS, USING THUMB RULES 12

3. In the case of M:N, put each eclass into a separate table; put the relationship itself into a third table with Pkey consisting of Pkeys from the M and N sides. In the case of 1:M, put each eclass into separate tables; Include the Pkey from the one side as a foreign key on the M side. 2. In the case of 1:1, put each eclass into a separate table, with a cross-reference key in either. 1. DESIGN FROM ER: 13 Following are the rules for converting an ER diagram into a design

PRODUCT WARRANTY HAS DESIGN FROM ER.. Prod#Descr War#Eff_Dt Warranty War# Eff_dt ??? Products Prod# Descr ??? 14 In the case of 1:1, put each eclass into a separate table and ____________________.

DESIGN FROM ER.. CUSTOMER ORDERS Places Cust#Name PRODUCTSAre for Customer Cust# Name Orders Ord# Ord_dt ???? Ord#Ord_dt 15 In the case of 1:M, put each eclass into a separate table and ___________.

ORDERS PRODUCTSAre for DESIGN FROM ER.. Ord#Ord_dtProd#Descr. Orders ord# ord_dt Products prod# descr Orders for Products ??? ???? qty Qty 16 In the case of M:N, put each _____ into a separate table and place the ___________ into a separate table with keys from ___ side and __ side

DISCUSSION DEVELOP DESIGNS FOR THE FOLLOWING SITUATIONS CAR DRIVER assigned EMPLOYEES PROJECT has COMPANY SUPPLIER supplies car#model SS#nameproj#mgr SS# title s#location. name addr. 17

THREE WAY AND HIGHER EMPLOYEES DEPT HAS emp#ti d#name 18 How can we do design with degree >= 3? PROJECTS proj# cost

DESIGN WITH NORMALIZATION 19

DESIGN USING NORMALIZATION Use normalization theory if: Data relationships complex No planning/ER done Maintenance Alternative to ER approach 20 Normalization: The process of designing well-structured tables.

DESIGN CONCEPTS FUNCTIONAL DEPENDENCIES 21

DESIGN CONCEPTS.. A relationship between two or more attributes such that if we know one attribute we can uniquely determine other attributes. Functional dependency: a --> b, c.. ; “a determines b, c..”, ; “b,c.. are dependent on a” 22 FD test: For each value of a there is one and only one value of b.

DESIGN CONCEPTS.. Functional dependency (FD): relationship between attributes (L -> R unless specified) a  b, c, d is referred to as a functional dependency diagram Each value of a is associated with one value of b; one c… For a given value of “b” (or “c”..) there can be many values of “a” 23 a b : a determines b, b is dependent on a a b : a does not determine b, no relationship (normally omitted) a b : there are multiple values of b for each a.

24 FD DIAGRAM EXAMPLES pp# name of issuing country flt# name of captain student id GPA player id team name pp# visa#’s GPA student id City name Hotel id price descr. gpa descr. Please note that FD is valid only in the first group; second group indicates need for additional keys (may result in partial functional dependencies)

FULL FD RULE relational Database Rule (Full functional dependency): All attributes must be fully dependent on the primary key ab c 25 Then they can be placed in a table with ____ as pkey.

FD WHEN DATA IS GIVEN ename --> phone#? phone# --> ename? ename  title? employee  dependents? EMPLOYEES 26 enamephone#titledependents Casey EngineerTracy, Tom Hugh ManagerNull Chris SecretaryAnn, Angie Franklin EngineerPat When data is given, perform FD test:

27 abc a1b1c1 a1b1c2 a2b2c3 FD WHEN DATA IS GIVEN.. a --> b? a  c? b  c?

FD WHEN DATA IS NOT GIVEN A flight (flt#) arrives or departs at one gate (gate#) A flight (flt#) can have one captain (captain name) A flight (flt#) can have one or more co-pilots (co-pilot name) A flight (flt#) can go to multiple destinations (dest. name) A flight (flt#) uses one or more altitudes (alt) A flight (flt#) has one or more attendants (attdt_name) A flight (flt#) has many crew members (cr_name) A flight (flt#) lands at one or more airports (a_code) When data is not given, make case by case assumptions and perform FD test. (Assumptions already given here): Note: FDs are split into pairs here for explanatory purposes 28

29 FD WHEN DATA IS NOT GIVEN.. l Cust places multiple orders l A flight has multiple pilots, but a single captain. l Each pet has a single owner l Each actor has an agent and one current project he/she is working on l relationship between ss# and user name for an online store? l User name, ss#, web site, company name, cust. credit card# When data is not given, make case by case assumptions and perform FD test. (Assumptions already given here):

Examples of FDs: SS# ---> Name, age, sex etc. Distance,Class --> Airfare. ISBN# --> Book title, price etc. DETERMINANTS & CANDIDATE KEYS The LHS of the FD is called a determinant, and is a candidate key. A candidate key is a key that can be used a pkey (usually LHS) Suppose a  b c -> b 30 What are the determinants? candidate keys? design?

THE FD APPROACH Suppose we have A --> B, C, D What will normalization yield? What is the foreign key here? 31

FUNCTIONAL DEPENDENCY RULES 1. Reflexive rule x -- > x e.g. ISBN# --> ISBN# 2. Union rule If x -> y and x --> z then x--> yz e.g. ISBN# --> title and ISBN# --> price then ISBN# --> title, price Transitivity rule If x--> y and y --> z then x--> z e.g. if VIN --> Model and Model --> Engine size then VIN --> Engine size;

FUNCTIONAL DEPENDENCY RULES.. 4. Substitution rule If x -> y and yz --> w then xz --> w e.g. if model --> processor and processor, buswidth --> speed then model, buswidth --> speed 33 equip#, p#  equip#, p# What rule is this? p#  descr P#  price => p#  descr, price What rule is this?

34 If part#  descr serial#  part# Then serial#  descr What rule is this? FUNCTIONAL DEPENDENCY RULES.. a -> b and b  c then a  c What rule is this? a -> b and a  c then a  ??? What rule is this?

FUNCTIONAL DEPENDENCY RULES.. Suppose the following FDs hold, a e  b, c, d f  a Then what is the primary key of the table b, c, d, e, f? 35

FUNCTIONAL DEPENDENCY DIAGRAMS DRAWING FD DIAGRAMS List all attributes (horizontally) placing candidate key leftmost Take each attribute (after candidate key) and find out its determinant if data is given, do the FD test with the data. if no data is given, make assumptions on a case by case basis. For each value of an attr, how many of the other attr. are there? If FD exists, draw single arrow if no FD do not draw the relationship if there are multiple values for each a, then draw a double arrow 36 The first step in design using FD approach is to draw an FD diagram:

NORMALIZATION PROCESS Identify and diagram the functional dependencies Group functional dependencies according to their determinants Place each set of FDs (along with determinants) in a separate table. Use determinants as the pkeys. Add appropriate foreign keys based on the application. THE FUNCTIONAL DEPENDENCY APPROACH 37

38 F.D. diagram: bid  location, mgr_nm, # of emp., mgr_join_dt. AN EXAMPLE OF FD APPROACH Draw FD between a bank id (bid), location, manager (mgr_nm), # of employees and Manager join date (mgr_join_dt) Group FDs according to common determinants: bid  location, mgr_nm, # of emp. mgr_nm  mgr_join_dt Develop design using notation below: Bank(bid, location, mgr_nm, #of emp) Manager(mgr_nm, mgr_join_dt) Check for cross reference keys

FOR DISCUSSION ord#: Unique identifier for order (an order can be for many parts) ord dt: date of order p#: unique number for parts qty: # of a certain part that is ordered c# : container for finished parts (one container per part) #fin: # of finished parts die#: Die used to manufacture parts (one die per part) shelf#: the shelf where the die is located 39 Draw an FD diagram and develop a design for the following situation: Strauble-Dytisa

REVIEW OF CONCEPTS Basic ConceptsDescription Ill structured table that is poorly designed; or has redundancies or more than one value at row- column intersection Well structured Table that is well designed; has no redundancies and atomic values at row- column intersection Anomaly An inconsistency during a database activity insert, delete or update Insertion anomaly An insertion anomaly occurs if when trying to add a record, it cannot be added without additional information or it may need to be added in multiple places instead of in one location. Deletion anomaly A deletion anomaly occurs, if when we try to delete a record, we have to perform the deletion a number of times, or if we lose information we did not intend to lose. Update anomaly An update anomaly occurs when making an update to a table, we have to update the same data in multiple places. Primary key An attribute whose value is unique within an entity class (table) e.g. SS#, Part# etc.

41 REVIEW OF CONCEPTS Basic ConceptsDescription Functional dependency A relationship between two or more attributes such that if we know a, we can uniquely determine b Fd test For each value of a there is one and only one b Full FD All attributes are fully functionally dependent on pkey Determinant LHS of a Functional Dependency (taken as candidate key) Candidate key A key that can serve as the primary key Foreign key/ Cross-reference key A key that serves as reference between two tables

42