Homework 1 Solution.

Slides:



Advertisements
Similar presentations
Banking Business Scenario
Advertisements

ER Modeling Case Studies
The Relational Model and Normalization (1)
Exercise 1 Consider the ER diagram below. Assume that an employee may work in up to two departments or may not be assigned to any department. Assume that.
Chapter 6: Entity-Relationship Model (part I)
ER Modeling Case Studies
Advanced Data Modeling
IELM 511: Information System design Introduction Part I. ISD for well structured data – relational and other DBMS Part II. ISD for systems with non-uniformly.
Database Systems: Design, Implementation, and Management Tenth Edition
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 6 Advanced Data Modeling.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 6 Advanced Data Modeling.
1 Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – EER Model –21th June.
E/R – ODL – UML CS145 Monday November 26 Sanaz Motahari-Asl.
DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design II (week 3)
--The Entity Relationship Model(2)--1 Reflexive Rela1tionships  An entity may be related to another entity of the same type.  Example: A Customer could.
Announcements - Spring 2015 March 2, 2015
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational Mapping.
The Enhanced E-R (EER) Model
Database Systems Chapter 7 ITM 354. Chapter Outline ER-to-Relational Schema Mapping Algorithm –Step 1: Mapping of Regular Entity Types –Step 2: Mapping.
Case study Lisa’s Bookstore IST210.
Introduction to Databases
Chapter 3: The Enhanced E-R Model
CSE 4701 Chapter 9-1 Chap 9 (6/5e): ER to Relational Transformation Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University.
ER Modeling Case Studies
Class Agenda – 04/04/2006 Discuss database modeling issues
Chapter 91 ER & EER to Relational Mapping. Chapter 92 ER to Relational Mapping Step 1: For each regular entity type E in the ER schema, create a relation.
ER- and EER-to-Relational Mapping
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008
©Silberschatz, Korth and Sudarshan6.1Database System Concepts Chapter 6: Integrity and Security Domain Constraints Referential Integrity Assertions Triggers.
Instructor :Huda Al-Omair
Introduction to Database Systems
Entity-Relationship Model Ch. 3
DATABASEMODELSDATABASEMODELS  A database model ◦ defines the logical design of data. ◦ Describes the relationships between different parts of data.
Other SQL Query Examples
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
Chapter 8 Data Modeling Advanced Concepts Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Assignements. CSC343: Intro. to Databases2 Exercise 1 Superkeys: Candidate keys: Primary key:
IST 220 – Intro to Databases Analyzing Data Needs.
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
An Entity Relationship (ER) Diagram is a graphic that shows the interrelationship between entities in a database.
Relational Database Design by ER- and EERR-to-Relational Mapping.
Data Modeling Using the Entity-Relationship (ER) Data Model (Based on Chapter 3 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
Database Systems: Design, Implementation, and Management Ninth Edition
Data Modeling Using the Entity-Relationship (ER) Data Model.
Relational Algebra HW2 Turn in as a hardcopy at the start of next class period. You may work this assignment in groups.
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
Introduction to Database Systems
Ch 05. Basic Symbols ( manino ). Cardinalities Cardinality Notation.
Relational Database Design by ER- and EER-to-Relational Mapping
Chapter 5 Understanding Entity Relationship Diagrams.
Data Modeling AND ER MODELS.
Data Modeling Advanced Concepts Updated 20/4/2015 TMC2034 Database Concept and Design1.
Year 12 > 13 Applied GCE ICT Unit 7 Using Database Software.
Databases (CS507) CHAPTER 7.
Relational Database Design by ER- and EER-to- Relational Mapping
Entity-Relationship Model
ER Diagram Practical Example
ER- and EER-to-Relational
DBMS LAB SESSION Pavan Kumar M.P B.E ,M.Sc(Tech) by Research,(Ph.D)
ER Modeling Case Studies
Entity-Relationship Model
CS4222 Principles of Database System
Foreign key (FK) is defined as follows:
ER Modeling Case Studies
Relational Database Design by ER- and EER-to- Relational Mapping
Relational Database Design by ER- and EER-to-Relational Mapping
Presentation transcript:

Homework 1 Solution

EER and EER for Pharmacy For ER 1-1, 1-m, m-n, and m-1 relationships Attribute definitions on entities - more than described. Primary MD as relationship Missing RX number from Prescription Entity For EER Use of extended ER constructs for inheritance Who can prescribe has changed Relationship between Prescriber and Patient Limit “Who” can prescribe to one of the options (use disjoint)

ER for Problem 1.1 name Phone# name email N 1 SSN Physician Patient Primary Physician specialty Patient address email address DEA# refills N dosage Prescribes date N Fill requirement pattern Sold By expiration price Purchasing Contract Drug name status start_date end_date

EER for Problem 1.2    DEA# N 1 SSN Physician Patient refills N Person Drug Prescriber    DEA# N 1 SSN Primary Physician Patient specialty refills N dosage Prescribes date N Fill requirement pattern Sold By expiration price Purchasing Contract Drug name status start_date end_date

EER for Problem 1.2 Notice Movement of Common Attributes to Person and DEA number to Presriber “Person” is a parent of both Patient and Physician and Physician also a Sub-entity of Drug Prescriber DEA# name phone address Drug Prescriber Person email    Physician Physician

Problem 3.19

Problem 3.23 a. Entity types: BANK, ACCOUNT, CUSTOMER, LOAN b. Weak entity type: BANK-BRANCH. Partial key: BranchNo. Identifying relationship: BRANCHES. c. The partial key BranchNo in BANK-BRANCH specifies that the same BranchNo value may occur under different BANKs. The identifying relationship BRANCHES specifies that BranchNo values are uniquely assigned for those BANK-BRANCH entities that are related to the same BANK entity. Hence, the combination of BANK Code and BranchNo together constitute a full identifier for a BANK-BRANCH.

Problem 3.23 d. Relationship Types: BRANCHES, ACCTS, LOANS, A-C, L-C. The (min, max) constraints are shown below.

Problem 3.23 e. The requirements may be stated as follows: Each BANK has a unique Code, as well as a Name and Address. Each BANK is related to one or more BANK-BRANCHes, and the BranchNo is unique among each set of BANK-BRANCHes that are related to the same BANK. Each BANK-BRANCH has an Address. Each BANK-BRANCH has zero or more LOANS and zero or more ACCTS. Each ACCOUNT has an AcctNo (unique), Balance, and Type and is related to exactly one BANK-BRANCH and to at least one CUSTOMER. Each LOAN has a LoanNo (unique), Amount, and Type and is related to exactly one BANK-BRANCH and to at least one CUSTOMER. Each CUSTOMER has an SSN (unique), Name, Phone, and Address, and is related to zero or more ACCOUNTs and to zero or more LOANs.

Problem 7.23a 3rd/6.18a 4th & 5th How many copies of the book titled The Lost Tribe are owned by the library branch whose name is ‘Sharpstown’? No_Of_Copies( (BranchName=‘Sharpstown’ (LIBRARY-BRANCH)) * BrachID (BOOKCOPIES *(Title=‘The Lost Tribe’ (BOOK))) ) BookId

Homework 2 Solution – 40 pt total For Problem 2.1 - 7.23/6.18 – a, b, c, and d No points for 7.23a/6.18a – solution posted on web 6 pts each for b and c 8 pts for d – see point breakdown on slide 2 Note – show using P(rojection), S(elect), *(join) Or the equivalent Greek letters For Problem 2.2 - 7.25/6.20 – a, b, and c 5pts a, 3 pts b, 4 pts c For Problem 2.3 - 7.27/6.22 – a, b, e, and f only 2 pts per table for each a, b, e, and f

Problem 7.23 3rd/6.18 4th & 5th – a to d a. P No_Of_Copies ( ( s BranchName='Sharpstown' (LIBRARY-BRANCH) ) * (BOOKCOPIES * ( s Title='The Lost Tribe’ (BOOK) ) ) ) b. P BranchID, No_Of_Copies ( ( s Title='The Lost Tribe' (BOOK)) * BOOKCOPIES * LIBRARY_BRANCH ) No_Of_Copies( (BranchName=‘Sharpstown’ (LIBRARY-BRANCH)) * BrachID (BOOKCOPIES *(Title=‘The Lost Tribe’ (BOOK))) ) BookId BranchName, No_Of_Copies( (Title=‘The Lost Tribe’ (BOOK)) * BOOKCOPIES * LIBRARY_BRANCH) BookId BrachId 2 pts each BookID and BranchId joins 1pt select, 1pt project

Problem 7.23 3rd/6.18 4th & 5th – a to d c. NO_CHECKOUT_B = P CardNo (BORROWER) - P CardNo (BOOK_LOANS) RESULT = P Name (BORROWER * NO_CHECKOUT_B) d. S = P BranchId ( s BranchName='Sharpstown' (LIBRARY-BRANCH) ) B_FROM_S = P BookId,CardNo ( ( s DueDate='today' (BOOKLOANS) ) * S ) RESULT = P Title,Name,Address ( BOOK * BORROWER * B_FROM_S ) NO_CHECKOUT_B =CardNo(BORROWER) - CardNo(BOOK_LOANS) ANSWER = Name(BORROWER * NO_CHECKOUT_B) 2 pts BORROWER – BOOK LOANS; 1pt for Project CardNo 2 pts BORROWER/NO_CHECKOUT_B join, 1 pt Project Name S =BranchID( BranchName=‘Sharpstwon’ (LIBRARY-BRANCH)) BranchId B_FROM_S = BookID, CardNo ( ( DueDate=‘Today’ (BOOKLOANS)) * S ) ANSWER = Title, Name, Address ( BOOK * BORROWER * B_FROM_S ) BookId CardNo 2 pts each BookID, CardNo, and BranchId joins ½ pt per each select or project

Problem 7.25 3rd/6.20 4th & 5th – a to c Schema is: SALESPERSON(Ssn, Name, Start_year, Dept_no) TRIP(Ssn, From_city, To_city, Departure_date, Return_date, Trip_id) EXPENSE(Trip_id, Account#, Amount) The schema of this question has the following two foreign keys: 1. the attribute SSN of relation TRIP that references relation SALESPERSON, and 2. the attribute Trip_ID of relation EXPENSE that references relation TRIP. In addition, the attributes Dept_No of relation SALESPERSON and Account# of relation EXPENSE are foreign keys referencing other relations of the database not mentioned in the question. 1.5 pt select, 1.5 pt project, 2 point join 1.5 pt select, 1.5 pt project 2 pt join, 1 select, 1 project a. COSTLY_TRIPS = ( SUM_Amount>2000(Trip_ID, SUM(Amount) (EXPENSE)) RESULT = TRIP * Trip_ID (COSTLY_TRIPS) b. RESULT = SSN (  To_City=‘Honolulu’ (TRIP)) c. RESULT = SUM(Amount) ( SSN=‘234-56-7890’ (TRIP) * EXPENSE )

Problem 7.27 3rd/6.22 4th & 5th – a to g