Relational Database Design Examples

Slides:



Advertisements
Similar presentations
Banking Business Scenario
Advertisements

ER Modeling Case Studies
ER Modeling Case Studies
System Analysis - Data Modeling
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
--The Entity Relationship Model(1)--1 The Entity Relationship Model.
CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.
Entity-Relationship (E-R) Model
Entity Relationship Model Chapter 6. Basic Elements of E-R Model Entity Object of the real world that stores data. Eg. Customer, State, Project, Supplier,
Data Modeling Using the Entity-Relationship Model
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
1 Advanced Computer Programming Databases. Overview What is a database? Database Basics Database Components Data Models Normalization Database Design.
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Lecture 4 Conceptual Data Modeling. Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship,
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
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 Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
ENTITY RELATIONSHIP MODELLING
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Transforming ER models to relational schemas
EntityRelationshipDiagrams. Entity Relationship Models The E-R (entity-relationship) data model views the real world as a set of basic objects (entities)
1 CS 430 Database Theory Winter 2005 Lecture 3: A Fifty Minute Introduction to Data Modeling.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Data Base Design Steps 1.Define Entity Classes (Relations/Tables) and Keys. 2.Define Relationships between Entity Classes. Normalization Steps Eliminate.
Chapter 7 Relational Database Design by ER- and EERR-to-Relational Mapping Copyright © 2004 Pearson Education, Inc.
Announcements Reading for Monday –Appendix A Homework 3 – Due today Project: Steps –Due 10/4 Exam 1 – 10/6.
Database Design Chapters 17 and 18.
Week 03 – ER Diagram INFOSYS 222.
Let try to identify the conectivity of these entity relationship
Data Modeling and the Entity-Relationship Model
Entity- Relationship (ER) Model
Chapter # 3 Data Modeling Using the Entity-Relationship (ER) Model
COP Introduction to Database Structures
Entity-Relationship Model
Entity Relationship Model
Chapter 4: Logical Database Design and the Relational Model
Chapter 4: Part B Logical Database Design and the Relational Model
Databases Chapter 16.
Entity-Relationship Model
Chapter -3- Data Modeling Using the Entity-Relationship Model
Chapter -3- Data Modeling Using the Entity-Relationship Model
Dept. of Computer & Information Sciences
Payroll Management System
ER MODEL Lecture 3.
ER Modeling Case Studies
بسم الله الرحمن الرحيم.
CSE2DBF – CSE4DBF E-R Model Examples 06/03/2017
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Relational Database Design (Top Down)
Database Systems Instructor Name: Lecture-11.
CSE2DBF – CSE4DBF EER Example 14/03/2017
Chapter 2 Modeling Data in the Organization
Database Modeling using Entity Relationship Model (E-R Model)
Review of Week 1 Database DBMS File systems vs. database systems
ER Modeling Case Studies
ER Modeling Case Studies
CHAPTER 2 - Database Requirements and ER Modeling
Chapter 7: Entity-Relationship Model
Entity-Relationship Diagram (ERD)
Relational Database Design
Entity Relation Model Tingting Zhang.
Conceptual modeling of databases
Database Management system
Database Management system
Relational Database Design Relational Database Design
Date: ____________________ Receipt #: _______________
Presentation transcript:

Relational Database Design Examples CSE2DBF – CSE4DBF Relational Database Design Examples 07/03/2017 Reading: Elmasri and Navathe, “Fundamentals of Database Systems, Chapter 9”, Pearson, 2017.

E-R Diagram Case (Real-Estate Agency) Properties are rented by tenants. Each tenant is assigned a unique number by the agency. Data held about each tenant includes family name, first name, contact address, phone number and property rented. A tenant may rent more than one property at any given time. Properties are owned by owners. Each property is assigned a unique building number. The agency only encourages a single owner for any of the properties it handles. The owner, address and value are recorded for each property. In addition, the lease period and bond, are recorded for each property rented. An owner may own several properties. Regular property maintenance is also recorded. The property, date, type of maintenance and cost are stored. Maintenance costs are charged to the property owner. Tenants pay accounts to the agency for each property they rent. These consists of date of payment, tenant, property, type of account (rental, Bond or damage) and the amount.

E-R Diagram Case (Real- Estate Agency) Owner# OwnerName OwnerAddress OWNER Maintenance# Date Type Cost 1 (1, N) Perform the complete transformation steps from the ‘Real Estate Agency’ ER Diagram. own Building# Address Value N (1, 1) (1, 1) incur (0, N) MAINTENANCE PROPERTY 1 N LeasePeriod Bond (0, N) 1 N (0,N) for rent (1, 1) Tenant# FamilyName Address FirstName Phone# ACCOUNT N ACReceipt# DateofPayment TypeOfAccount AmountPaid N (1, 1) M (1, N) pay TENANT (1, N) 1

E-R Diagram Case (Real-Estate Agency) STEP 1: OWNER ( Owner #, Owner Name, Owner Address) PROPERTY ( Building#, Address, Value) TENANT(Tenant#, Family Name, First Name, Contact Address, Phone#) MAINTENANCE (Maintenance#, Date, Type, Cost) ACCOUNT( Acct Receipt#, DateofPayment, TypeofAccount, AmountPaid) STEP 2: no weak entity STEP 3: no 1 To 1 relationship STEP 4: 1 To N between OWNER and PROPERTY The PROPERTY relation is modified: PROPERTY (Building#, Address, Value, Owner#)

E-R Diagram Case (Real-Estate Agency) STEP 4: 1 To N between PROPERTY and MAINTENANCE The MAINTENANCE relation is modified to: MAINTENANCE(Maintenance#, Date, Type, Cost, Building#) STEP 4: 1 To N between TENANT and ACCOUNT The ACCOUNT relation is modified to: ACCOUNT( Acct Receipt#, DateofPayment, TypeofAccount, AmountPaid, Tenant#) STEP 4: 1 To N between PROPERTY and ACCOUNT The ACCOUNT relation is modified to: ACCOUNT( Acct Receipt#, DateofPayment, TypeofAccount, AmountPaid, Tenant#, Building#)

E-R Diagram Case (Real-Estate Agency) STEP 5: M to N relationship between TENANT and PROPERTY The RENT relation is created: RENT (Building#, Tenant#, LeasePeriod, Bond) STEP 6: no multivalued attribute. STEP 7: no ternary relatiosnhip

E-R Diagram Case (Real-Estate Agency) Finally, the end result of the transformation can be listed as follows. OWNER ( Owner #, Owner Name, Owner Address) PROPERTY (Building#, Address, Value, Owner#) TENANT(Tenant#, Family Name, First Name, Contact Address, Phone#) MAINTENANCE(Maintenance#, Date, Type, Cost, Building#) ACCOUNT( Acct Receipt#, DateofPayment, TypeofAccount, AmountPaid, Tenant#, Building#) RENT(Building#, Tenant#, LeasedPeriod, Bond) Step 1 Step 4 Step 1 Step 4 Step 4 Step 5

E-R Diagram Case (Food Plan Database) Extracted from a past exam A database on food plan is to be maintained that can store any number of plans. Each plan is given a unique food plan id. The plan-designer and plan-creation-date are stored for each food plan. Each plan may be made up of any number of servings, each of which is given a unique serving-name. A time-of-serving attribute is stored for each serving within a food plan. A serving-description is stored for each serving.   Each serving is made up of any amount of any number of food elements. For example, one particular serving may be made up of 10g of beef, 20g potatoes, 5g of tomatoes, and 3g of peas. A food-id is used for each element, and a field food-description is stored for each food element.

E-R Diagram Case (Food Plan Database) To allow the nutritional value of each plan to be computed, nutrient values are associated with each food element, as follows: A set of nutrients (eg. VitA, VitB, etc.) is stored with their unit-of measure (eg. IU [International Unit] for VitA, mg [milligrams] for VitB, etc.). A nutrient-id and a nutrient-description are also stored. The nutrient-content for each nutrient that applies to a particular food is stored for a standard-amount of that food. A patient is assigned a food plan on each day of his or her stay. Only one food plan applies to one patient on the one day, but patient may have different food plans on different days. A patient-id and patient-details are stored for each patient.   Develop an ER model for the above problem definition. The ER should contain necessary information such as entities, attributes, primary keys, relationships, cardinalities, and participation. Any assumptions should also be stated.

E-R Diagram Case (Food Plan Database) ServingName consists_of FOODPLAN M (1, N) (1, N) N SERVING ServDesc FPlanID Designer TimeOfServing M (1, N) M (1, N) CreationDate includes applies_to Amount Date N (1, N) N (1, N) PatientID PATIENT FOODELEMENT ElementID Name ElementDesc Address M (1, N) Perform the complete transformation steps from the ‘Food Plan Database’ ER Diagram. DOB contains StandardAmount N (0, N) NutritionContent NUTRIENT NutrientID NutrientDesc UnitMeasurement

E-R Diagram Case (Food Plan Database) STEP 1: FOODPLAN (FPlanID, Designer, CreationDate) SERVING (ServingName, ServingDesc) FOODELEMENT(ElementID, ElementDesc) NUTRIENT (NutrientID, NutrientDesc, UnitMeasure) PATIENT( PatientID, Name, Address, DOB) STEP 2: no weak entity STEP 3: no 1 To 1 relationship STEP 4: no 1 To N relationship

E-R Diagram Case (Food Plan Database) STEP 5: M to N relationship between FOODPLAN and SERVING The CONSISTSOF relation is created: CONSISTSOF (FPlanID, ServingName, TimeofServing) STEP 5: M to N relationship between SERVING and FOODELEMENT The INCLUDES relation is created: INCLUDES (ServingName, ElementID, Amount) STEP 5: M to N relationship between FOODELEMENT and NUTRIENTS The CONTAINS relation is created: CONTAINS (ElementID, NutrientsID, StandardAmount, NutritionContent) STEP 5: M to N relationship between FOODPLAN and PATIENT The APPLIESTO relation is created: APPLIESTO (FPlanID, PatientID, Date)

E-R Diagram Case (Real-Estate Agency) STEP 6: no multivalued attribute. STEP 7: no ternary relatiosnhip Finally, the end result of the transformation can be listed as follows. FOODPLAN (FPlanID, Designer, CreationDate) SERVING (ServingName, ServingDesc) FOODELEMENT(ElementID, ElementDesc) NUTRIENT (NutrientID, NutrientDesc, UnitMeasure) PATIENT( PatientID, Name, Address, DOB) CONSISTSOF (FPlanID, ServingName, TimeofServing) INCLUDES (ServingName, ElementID, Amount) CONTAINS (ElementID, NutrientsID, StandardAmount, NutritionContent) APPLIESTO (FPlanID, PatientID, Date) Step 1 Step 5

EER Modelling and Transformation Next Lecture EER Modelling and Transformation Reading: Elmasri and Navathe, “Fundamentals of Database Systems, Chapters 4 & 9”, Pearson, 2017