Database Design April 3, 2002. Projects, More Details Goal: build a DB application. (almost) anything goes. Groups of 3-4. End of week 2: groups formed.

Slides:



Advertisements
Similar presentations
Why Object-Oriented DBMS? Abstract data types Interface with host programming language (the impedance mismatch). Object identity: (peter, 40, {(john, 15,
Advertisements

Information Systems Chapter 4 Relational Databases Modelling.
ODMG Standard: Object Model1 OBJECT-ORIENTED DATABASE SYSTEMS ODMG Standard: Object Model Susan D. Urban and Suzanne W. Dietrich Department of Computer.
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.
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:
Programs with SQL Host language + Embedded SQL Preprocessor Host Language + function calls Host language compiler Host language program Preprocessor Host.
1 Lecture 3: Database Modeling (continued) April 5, 2002.
1 Conceptual Design with ER Model Lecture #2. 2 Lecture Outline Logistics Steps in building a database application Conceptual design with ER model.
1 The Entity-Relationship Data Model Chapter 2 (Database Design)
Database Management Systems CSE 594 Lecture #1 April 4 th, 2002.
Databases Illuminated Chapter 7 The Object-Oriented Model.
Lecture 9: Conceptual Database Design January 27 th, 2003.
Multiplicity in E/R Diagrams
Functional Dependencies and Relational Schema Design.
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
Entity / Relationship Diagrams Objects entities Classes entity sets Attributes are like in ODL. Relationships: like in ODL except - not associated with.
Why Object-Oriented DBMS? Abstract data types (relational data model is too simple). Interface with host programming language Managing large number of.
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.
Entity-Relationship Data Model N. Harika Lecturer(csc)
Lecture 2: E/R Diagrams and the Relational Model Thursday, January 4, 2001.
Database Management COP4540, SCS, FIU Database Modeling A Introduction to object definition language (ODL)
Object Definition Language
Conceptual Database Design. Building an Application with a DBMS Requirements modeling (conceptual, pictures) –Decide what entities should be part of the.
Object Definition Language
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.
Lecture 2: E/R Diagrams and the Relational Model Wednesday, April 3 rd, 2002.
Database Design Why do we need it? – Agree on structure of the database before deciding on a particular implementation. Consider issues such as: –What.
Essential Databases The simple truth!. What’s a database? A system which helps with –storage –retrieval in an efficient manner –assume large volumes of.
1 The Entity- Relationship Model Instructor: Mohamed Eltabakh
© D. Wong Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:
Lecture 3: Conceptual Database Design and Schema Design April 12 th, 2004.
COMP 430 Intro. to Database Systems Entity-Relationship Diagram Basics Slides use ideas from Chris Ré.
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
1 Lecture 8: SQL Programming and Transactions Friday, January 24, 2003.
COMP 430 Intro. to Database Systems ER Design Considerations Slides use ideas from Chris Ré.
High-level Database Models Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
1 Database Modeling (Semantic data modeling) ER Data Model –A high-level conceptual data model –Proposed by P. Chen (1976) –Widely used in DB design process.
The Relational Data Model Database Model (ODL, E/R) Relational Schema Physical storage ODL definitions Diagrams (E/R) Tables: row names: attributes rows:
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.
(Ref: ODMG2.0, R Cattell et al, Morgan Kaufmann, 1997)
Database Design Oct. 3, 2001.
Database Design Why do we need it? Consider issues such as:
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
Lecture 4: Database Modeling (continued)
Cse 344 May 11th – Entities.
Lecture 06 Data Modeling: E/R Diagrams
CSE544 Lecture 1: Introduction
name category name price makes Company Product stockprice buys employs
Functional Dependencies
CMPT 354: Database System I
Lecture 8: The E/R Model I
Lecture 9: The E/R Model II
Functional Dependencies
Lecture 5: The Relational Data Model
Functional Dependencies
Lecture 06: SQL Monday, October 11, 2004.
CS4433 Database Systems E-R Model.
Syllabus Introduction Website Management Systems
Presentation transcript:

Database Design April 3, 2002

Projects, More Details Goal: build a DB application. (almost) anything goes. Groups of 3-4. End of week 2: groups formed. End of week 3: proposals, E/R diagrams End of week 5: project specs due End of week 7: sample end-to-end app due June 7th: demos

Building an Application with a DBMS Requirements modeling (conceptual, pictures) –Decide what entities should be part of the application and how they should be linked. Schema design and implementation –Decide on a set of tables, attributes. –Define the tables in the database system. –Populate database (insert tuples). Write application programs using the DBMS –way easier now that the data management is taken care of.

Outline ODL - Object Definition Language (2.1) E/R - Entity relationship diagrams (2.2) Design Principles (2.3)

Database Design Why do we need it? – Agree on structure of the database before deciding on a particular implementation. Consider issues such as: –What entities to model –How entities are related –What constraints exist in the domain –How to achieve good designs

Database Design Formalisms 1. Object Definition Language (ODL): – Closer in spirit to object-oriented models 2. Entity/Relationship model (E/R): –More relational in nature. Both can be translated (semi-automatically) to relational schemas ODL to OO-schema: direct transformation (C++ or Smalltalk based system).

1. Object Definition Language ODL is part of ODMG superset of Corba’s IDL Resembles C++ (and Smalltalk).

ODL Principles Basic design paradigm in ODL: –Model objects and their properties. For abstraction purposes: –Group objects into classes. What qualifies as a good class? –Objects should have common properties.

ODL Class Declarations Class declaration: Methods: arbitrary function, of little concern for us here Interface { attributes: ; relationships ; methods (param) }

ODL Example Product Person Company category name price name stockprice name addressssn

ODL Declarations Interface Product { attribute string name; attribute float price; attribute enum Categories {electronics, communications, sports …} category } Interface Company { attribute string name; attribute float stockprice; } Interface Person { attribute integer ssn; attribute string name; attribute struct Address {string street, string city} address; } Interface Product { attribute string name; attribute float price; attribute enum Categories {electronics, communications, sports …} category } Interface Company { attribute string name; attribute float stockprice; } Interface Person { attribute integer ssn; attribute string name; attribute struct Address {string street, string city} address; } So far just simplified C++ with slightly different syntax

ODL Example Extended Product Person Company category name price name stockprice name addressssn buys worksFor madeBy

ODL Declarations, Extended Interface Product { attribute string name; attribute float price; attribute enum Categories {electronics, communications, sports …} category; relationship madeBy; } Interface Person { attribute integer ssn; attribute string name; attribute Struct Address {string street, string city} address; relationship set buys; relationship set worksFor;} Interface Product { attribute string name; attribute float price; attribute enum Categories {electronics, communications, sports …} category; relationship madeBy; } Interface Person { attribute integer ssn; attribute string name; attribute Struct Address {string street, string city} address; relationship set buys; relationship set worksFor;} relationship corresponds somewhat to pointers in C++

ODL Example, Extended Again Product Person Company category name price name stockprice name addressssn buys worksFor madeBy employs makes

ODL Declarations, Extended Again Interface Company { attribute string name; attribute float stockprice; relationship set makes inverse Product::madeBy; relationship set employs inverse Person::worksFor; } Interface Company { attribute string name; attribute float stockprice; relationship set makes inverse Product::madeBy; relationship set employs inverse Person::worksFor; }

Types in ODL Basic types: Atomic types (e.g., string, integer, …) Interface types (e.g., Person, Product, Company) Constructors: collection types: Set: {1, 5, 6} Bag: {1, 1, 5, 6, 6 } List: [1, 5, 6, 1, 6 ] Array: integer[17] structured types: Struct {string street, string city, integer zipcode}

Collection Types Sets: –order, number of occurrences don’t matter –{4,7,9} = {7,9,7,4} = {9,4,7} Bags: –number of occurrences matter, order not: –{7,9,7,4}={7,7,9,4}, is different from {4,7,9} Lists: –order, number of occurrences matter: –[4,7,9] different from [9,4,7]

Allowable Types in ODL For attributes: atomic/struct, or collection of atomic/struct OK: string, set Not OK: Product, set > For relationships: interface, or collection of interface. OK: Product, set, list Not OK: struct {pname Product, cname Company} set > integer

2. Entity / Relationship Diagrams Objects entities Classes entity sets Attributes are like in ODL. Relationships: like in ODL except - first class citizens (not associated with classes) - not necessarily binary Product address buys

address namessn Person buys makes employs Company Product namecategory stockprice name price

What is a Relation ? A mathematical definition: –if A, B are sets, then a relation R is a subset of A x B A={1,2,3}, B={a,b,c,d}, R = {(1,a), (1,c), (3,b)} - makes is a subset of Product x Company: a b c d A= B= makes Company Product

Multiplicity of E/R Relations one-one: many-one many-many abcdabcd abcdabcd abcdabcd

Multi-way Relationships How do we model a purchase relationship between buyers, products and stores? Purchase Product Person Store Can still model as a mathematical set (how ?)

Q: what does the arrow mean ? A: if I know the store, person, invoice, I know the movie too Rental VideoStore Person Movie Invoice Arrows in Multiway Relationships

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

Q: how do I say: “invoice determines store” ? A: no good way; best approximation: Q: Why is this incomplete ? Rental VideoStore Person Movie Invoice Arrows in Multiway Relationships

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

Attributes on Relationships Purchase Product Person Store date

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

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

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

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