1 Lecture 3: Database Modeling (continued) April 5, 2002.

Slides:



Advertisements
Similar presentations
Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Advertisements

Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Information Systems Chapter 4 Relational Databases Modelling.
Lecture 6: Design Constraints and Functional Dependencies January 21st, 2004.
1 Relational Model and Translating ER into Relational.
1 Lecture 04 Entity/Relationship Modelling. 2 Outline E/R model (Chapter 5) From E/R diagrams to relational schemas (Chapter 5) Constraints in SQL (Chapter.
Lecture #2 October 5 th, 2000 Conceptual Modeling Administration: –HW1 available –Details on projects –Exam date –XML comment.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
Functional Dependencies Definition: If two tuples agree on the attributes A, A, … A 12n then they must also agree on the attributes B, B, … B 12m Formally:
1 Conceptual Design with ER Model Lecture #2. 2 Lecture Outline Logistics Steps in building a database application Conceptual design with ER model.
Murali Mani The Entity- Relationship Model. Murali Mani Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
Lecture 9: Conceptual Database Design January 27 th, 2003.
Multiplicity in E/R Diagrams
The Relational Data Model Database Model (ODL, E/R) Relational Schema Physical storage ODL definitions Diagrams (E/R) Tables: row names: attributes rows:
1 Lecture 4: Database Modeling (end) The Relational Data Model April 8, 2002.
CS411 Database Systems Kazuhiro Minami
Database Design April 3, Projects, More Details Goal: build a DB application. (almost) anything goes. Groups of 3-4. End of week 2: groups formed.
The Entity-Relationship Model. 421B: Database Systems - ER Model 2 Overview of Database Design q Conceptual Design -- A first model of the real world.
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Entity / Relationship Diagrams Objects entities Classes entity sets Attributes are like in ODL. Relationships: like in ODL except - not associated with.
CS411 Database Systems Kazuhiro Minami 02: The Entity-Relationship Model.
Principles of Database Systems With Internet and Java Applications Today’s Topic Chapter 2: Representing Information with Data Models The lecture notes.
E/R Diagrams and Functional Dependencies. Modeling Subclasses The world is inherently hierarchical. Some entities are special cases of others We need.
Lecture 08: E/R Diagrams and Functional Dependencies.
Lecture 2: E/R Diagrams and the Relational Model Thursday, January 4, 2001.
Database Systems Lecture # 7 8 th Feb, Conceptual and Logical Design Person buys Product name pricenamessn Conceptual Model: Relational Model: (plus.
CS 564 Database Management Systems: Design and Implementation
Conceptual Database Design. Building an Application with a DBMS Requirements modeling (conceptual, pictures) –Decide what entities should be part of the.
1 Introduction to Database Systems CSE 444 Lecture 07 E/R Diagrams October 10, 2007.
Tallahassee, Florida, 2015 COP4710 Database Systems E-R Model Fall 2015.
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
Lecture 2: E/R Diagrams and the Relational Model Wednesday, April 3 rd, 2002.
Home Work. Design Principles and Weak Entity Sets.
CMPT 258 Database Systems The Relationship Model PartII (Chapter 3)
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
Lecture 3: Conceptual Database Design and Schema Design April 12 th, 2004.
The Entity-Relationship Model CIS 4301 Lecture Notes 1/12/2006.
1 Lecture 08: E/R Diagrams and Functional Dependencies Friday, January 21, 2005.
Mapping E/R to RM, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 Mapping E/R Diagrams to Relational Database Schemas Second Half of Chapter.
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
COMP 430 Intro. to Database Systems ER Design Considerations Slides use ideas from Chris Ré.
CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles.
High-level Database Models Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
Lecture 4: The E/R Model Lecture 4 Today’s Lecture 1.E/R Basics: Entities & Relations ACTIVITY: Crayon time! 2.E/R Design considerations ACTIVITY: Crayon.
CS422 Principles of Database Systems Entity-Relationship Model
Lecture 5: Conceptual Database Design
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
COP4710 Database Systems E-R Model.
Database Design Oct. 3, 2001.
Database Design Why do we need it? Consider issues such as:
Database Management Systems (CS 564)
Lecture 4 Lecture 4: The E/R Model.
02: ER Model Ch 4.1 – 4.4 Optionally, begin with Ch 2.1.
Conceptual Database Design
Constraints in Entity-Relationship Models
Translation of ER-diagram into Relational Schema
From E/R Diagrams to Relational Schema
Lecture 4: Database Modeling (continued)
Cse 344 May 11th – Entities.
Lecture 2: Database Modeling (end) The Relational Data Model
Lecture 06 Data Modeling: E/R Diagrams
name category name price makes Company Product stockprice buys employs
Functional Dependencies
Lecture 9: The E/R Model II
Lecture 10: The E/R Model III
Lecture 5: The Relational Data Model
Lecture 06: SQL Monday, October 11, 2004.
CS4433 Database Systems E-R Model.
Presentation transcript:

1 Lecture 3: Database Modeling (continued) April 5, 2002

2 Q: what do these arrow mean ? A: store, person, invoice determines movie and store, invoice, movie determines person Rental VideoStore Person Movie Invoice Arrows in Multiway Relationships: Correction

3 Roles in Relationships Purchase What if we need an entity set twice in one relationship? Product Person Store salesperson buyer

4 Attributes on Relationships Purchase Product Person Store date

5 Converting Multi-way Relationships to Binary Purchase Person Store Product StoreOf ProductOf BuyerOf date

6 Design Principles Purchase Product Person What’s wrong? President PersonCountry Moral: be faithful!

7 Design Principles: What’s Wrong? Purchase Product Store date personName personAddr Moral: pick the right kind of entities.

8 Design Principles: What’s Wrong? Purchase Product Person Store date Dates Moral: don’t complicate life more than it already is.

9 Next Attactions Subclasses (2.4) Constraints: (2.5) Weak entity sets (2.6)

10 Modeling Subclasses Some objects in a class may be special define a new class better: define a subclass Products Software products Educational products So --- we define subclasses (in ODL and in E/R).

11 Subclasses in ODL interface SoftwareProduct: Product{ attribute string platform; attribute integer requiredMemory; } interface EducationalProduct: Product{ attribute struct Interval {integer begin, integer end} ageGroup; attribute string topic; } interface SoftwareProduct: Product{ attribute string platform; attribute integer requiredMemory; } interface EducationalProduct: Product{ attribute struct Interval {integer begin, integer end} ageGroup; attribute string topic; } The two classes inherit all the properties of Product.

12 Understanding Subclasses Think in terms of records: –Product –SoftwareProduct –EducationalProduct field1 field2 field1 field2 field1 field2 field3 field4 field5

13 Multiple Inheritance in ODL Product Educational Product Educ-software Product Software Product ageGroup topic Platforms required memory Educational-method

14 interface EducSoftwareProduct: SoftwareProduct, EducationalProduct { attribute string educational-method; } interface EducSoftwareProduct: SoftwareProduct, EducationalProduct { attribute string educational-method; }

15 Understanding Multiple Inheritance Think in terms of records: –EducSoftwareProduct field1 field2 field3 field4 field5

16 How do we resolve conflicts? Product Educational Product Educ-software Product Software Product ageGroup topic Platforms required memory Educational-method Rating (ATA) Rating (ASA) Rating?

17 Product namecategory price isa Educational ProductSoftware Product Age Groupplatforms Subclasses in E/R Diagrams

18 ODL: classes are disjoint p1 p2 p3 sp1 sp2 ep1 ep2 ep3 Difference between ODL and E/R inheritance Product SoftwareProduct EducationalProduct

19 E/R: entity sets overlap Difference between ODL and E/R inheritance SoftwareProduct EducationalProduct p1 p2 p3 sp1 sp2 ep1 ep2 ep3 Product

20 No need for multiple inheritance in E/R we have three entity sets, but four different kinds of objects SoftwareProduct EducationalProduct p1 p2 p3 sp1 sp2 ep1 ep2 ep3 Product esp1 esp2

21 Constraints A constraint = an assertion about the database that must be true at all times part of the db schema types in programming languages do not have anything similar correspond to invariants in programming languages

22 Modeling Constraints Finding constraints is part of the modeling process. Commonly used constraints: Keys: social security number uniquely identifies a person. Single-value constraints: a person can have only one father. Referential integrity constraints: if you work for a company, it must exist in the database. Domain constraints: peoples’ ages are between 0 and 150. General constraints: all others (at most 50 students enroll in a class)

23 Keys A set of attributes that uniquely identify an object or entity: Person: social-security-number name name + address name + address + age Perfect keys are often hard to find, so organizations usually invent something.

24 Keys Multi-attribute keys: –E.g. name + address Multiple keys: –E.g social-security-number, name + address

25 Keys in ODL Defining multiple keys: (key ssn employeID (name address age)) interface Person (key ssn) { attribute string ssn; attribute string name;... }

26 Keys in E/R Diagrams address namessn Person Product namecategory price No formal way to specify multiple keys in E/R diagrams Underline:

27 Single Value Constraints Sometimes we can choose to allow one or more values ODL: –attributes are always single value –relationships have single or multiple values relationship person president; relationship set presidents;

28 Single Value Constraints E/R: offers

29 Single Value Constraints Single Value Constraint: we explicitly require one value two flavors: –allow nulls –do not allow nulls

30 Referential Integrity Constraints In some formalisms we may refer to other object but get garbage instead –e.g. a dangling pointer in C/C++ the Referential Integrity Constraint explicitly requires a reference to exists

31 Referential Integrity Constraints In ODL: – means that a relationship cannot be NULL In E/R: CompanyProduct makes CompanyProduct makes

32 Weak Entity Sets Entity sets are weak when their key attributes come from other classes to which they are related. This happens if: - part-of hierarchies - splitting n-ary relations to binary. UniversityTeam affiliation numbersportname