Presentation is loading. Please wait.

Presentation is loading. Please wait.

Information Systems Chapter 4 Relational Databases Modelling.

Similar presentations


Presentation on theme: "Information Systems Chapter 4 Relational Databases Modelling."— Presentation transcript:

1 Information Systems Chapter 4 Relational Databases Modelling

2 Database design Modelling –Decide which part of reality is represented in a database –Agree on structure of the database before deciding on a particular implementation Conceptual Modelling –oriented towards application and users –independent of technology and implementation

3 Some Terminology Classes of similar objects (and their relationships) students Instances Student -name -firstname -birthdate -section -year Type (of table) Database Etudiant (relational) Schema Real world perceptionAbstraction / Description E/R Diagram Class

4 Conceptual Modelling Consider issues such as: –What entities to model –How entities are related –What constraints exist in the domain –How to achieve good designs

5 Database Design Formalisms 1. Entity/Relationship model (E/R): –More relational in nature. –Very widely used 2. Object Definition Language (ODL): –Closer in spirit to object-oriented models (e.g. Java) –Will not be covered Both can be translated (semi-automatically) to relational schemas

6 2. Entity / Relationship Diagrams Objects entities Classes entity sets Attributes. Relationships: - bidirectional Product Price Order

7 Company Name StockPrice Person ssn Name Adress Product Name Price Category makesemploysbays

8 Keys in E/R Diagrams Every entity set must have a key –a key is an attribute that has a different value for every entity Product Name Price Category

9 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: 1 2 3 a b c d A= B= Company Name StockPrice Product Name Price Category makes

10 Multiplicity of E/R Relations one-one: many-one many-many 123123 abcdabcd 123123 abcdabcd 123123 abcdabcd 11 N1 NN

11 Multiplicity of E/R Relations (2) (arrows notation) one-one: many-one many-many 123123 abcdabcd 123123 abcdabcd 123123 abcdabcd

12 Company Name StockPrice Person ssn Name Adress Product Name Price Category makesemploysbays N NN N 1 1 What does this say ? Person ssn Name Adress Product Name Price Category

13 Multi-way Relationships How do we model a purchase relationship between buyers, products and stores? Person ssn Name Adress Product Name Price Category purchase N Person ssn Name Adress Product Name Price Category Store Number Adress N N

14 Multiplicity in Multiway Relationships Q: what does the multiplicity 1 mean ? A: if I know the store, person, invoice, I know the movie too VideoStore Person Movie Invoice rental N N N 1

15 Multiplicity in Multiway Relationships Q: what do the multiplicities 1 mean ? A: store, person, invoice determines movie and store, invoice, movie determines person VideoStore Person Movie Invoice rental N N 1 1

16 Attributes on Relationships Person ssn Name Adress Product Name Price Category Purchase date N Person ssn Name Adress Product Name Price Category Store Number Adress N N

17 Converting Multi-way Relationships to Binary BuyerOf Product Name Price Category Product Name Price Category Store Number Adress N Person ssn Name Adress Person ssn Name Adress N Purchase Date ProductOf StoreOf N N N N

18 4. From E/R Diagrams to Relational Schema Entity set  relation Relationship  relation

19 Entity Set to Relation Product(name, category, price) name category price gizmo gadgets $19.99 Product Name Price Category

20 Relationships to Relations Makes(product-name, company-name, year) Product-name Product-Category Company-name year gizmo gadgets gizmoWorks 1963 (watch out for attribute name conflicts) Company Name StockPrice Product Name Price Category makes Year N N Product Name Price Category

21 Relationships to Relations No need for Makes. Modify Product: name category price companyName gizmo gadgets 19.99 gizmoWorks Company Name StockPrice Product Name Price Category makes 1 N Product Name Price Category

22 Multi-way Relationships to Relations Person ssn Name Adress Product Name Price Category Purchase date N Person ssn Name Adress Product Name Price Category Store Number Adress N N Purchase(prodName,stName,ssn,date)

23 4. Design Principles What’s wrong? Product Person Country Moral: be faithful! Purchase President

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

25 Product Person Store Dates date Moral: don’t complicate life more than it already is. Purchase

26 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 E/R

27

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

29 Subclasses to Relations NamePriceCategory Gizmo99gadget Camera49photo Toy39gadget Nameplatforms Gizmounix NameAge Group Gizmotodler Toyretired Product Sw.Product Ed.Product

30 Modeling Subclass Structure

31 5. Constraints in E/R Diagrams 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. Other constraints: peoples’ ages are between 0 and 150.

32 Keys in E/R Diagrams No formal way to specify multiple keys in E/R diagrams Underline:


Download ppt "Information Systems Chapter 4 Relational Databases Modelling."

Similar presentations


Ads by Google