Lecture 4: Database Modeling (continued)

Slides:



Advertisements
Similar presentations
Information Systems Chapter 4 Relational Databases Modelling.
Advertisements

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.
1 Lecture 3: Database Modeling (continued) April 5, 2002.
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
CS411 Database Systems Kazuhiro Minami 02: The Entity-Relationship Model.
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.
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.
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
ER Diagrams and Relational Model CS 174a (Winter 2015)
CS422 Principles of Database Systems Entity-Relationship Model
COP Introduction to Database Structures
Comp 1100 Entity-Relationship (ER) Model
Relational Database Design by ER- and ERR-to-Relational Mapping
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.
Enhanced Entity-Relationship and Object Modeling Objectives
Relational Database Design by ER- and EER-to- Relational Mapping
COP4710 Database Systems E-R Model.
Enhanced Entity-Relationship (EER) Modeling
Database Design Oct. 3, 2001.
Database Design Why do we need it? Consider issues such as:
RELATION.
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.
ER- and EER-to-Relational
Constraints in Entity-Relationship Models
9/5/2018.
Cse 344 March 2nd – E/r diagrams.
Translation of ER-diagram into Relational Schema
Cse 344 May 14th – Entities.
11/15/2018.
From E/R Diagrams to Relational Schema
Overview of Database Systems
Lecture 2: Database Modeling (end) The Relational Data Model
Chapter 8: Mapping a Conceptual Design into a Logical Design
Lecture 06 Data Modeling: E/R Diagrams
Relational Database Design by ER- and EER-to-Relational Mapping
name category name price makes Company Product stockprice buys employs
CMPT 354: Database System I
Lecture 10: The E/R Model III
Lecture 5: The Relational Data Model
Relational Database Design by ER- and EER-to- Relational Mapping
Sampath Jayarathna Cal Poly Pomona
Relational Database Design by ER- and EERR-to-Relational Mapping
4/11/2019.
CS4433 Database Systems E-R Model.
Enhanced Entity-Relationship (EER) Modeling
Relational Database Design by ER- and EER-to-Relational Mapping
Enhanced Entity-Relationship (EER) Modeling
Lecture 08: E/R Diagrams and Functional Dependencies
The Entity-Relationship Model
Overview of Database Systems
Database Dr. Roueida Mohammed.
7/19/2019.
CS4222 Principles of Database System
Presentation transcript:

Lecture 4: Database Modeling (continued) Oct. 8, 2001

Outline Subclasses (2.4) Constraints: (2.5) Weak entity sets (2.6)

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).

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; The two classes inherit all the properties of Product.

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

Subclasses for Heterogeneous Collections Now consider a class referring to Product: Some offers are Product, others are SoftwareProduct, or EducationalProduct interface Vendor { attribute string name; relationshiop Set<Product> offers; }

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

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

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

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

Subclasses in E/R Diagrams name category price Product isa isa Software Product Educational Product platforms Age Group

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

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

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

Modeling UnionTypes With Subclasses FurniturePiece Person Company Say: each piece of furniture is owned either by a person, or by a company

Modeling Union Types with Subclasses Say: each piece of furniture is owned either by a person, or by a company Solution 1. Acceptable, imperfect (What’s wrong ?) FurniturePiece Person Company ownedByPerson

Modeling Union Types with Subclasses Solution 2: better, more laborious Owner isa isa ownedBy Person Company FurniturePiece

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

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)

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.

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

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

Keys in E/R Diagrams name category Underline: price Product No formal way to specify multiple keys in E/R diagrams Person name ssn address

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<person> presidents;

Single Value Constraints E/R: offers

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

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

Referential Integrity Constraints In ODL: means that a relationship cannot be NULL In E/R: makes Product Company makes Product Company

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. affiliation Team University sport number name