Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hele-Mai Haav: CSC210-Spring*01 CSC230-Spring*03 Database Design.

Similar presentations


Presentation on theme: "Hele-Mai Haav: CSC210-Spring*01 CSC230-Spring*03 Database Design."— Presentation transcript:

1 Hele-Mai Haav: CSC210-Spring*01 CSC230-Spring*03 Database Design

2 The process of designing a database begins with an analysis of what information the database must hold and the relationships among components of that information. The structure of the database is called the database schema and it is specified in one of database design languages (e.g. E/R or ODL) If the design is committed to a form in which it can be put to a DBS, then the database takes physical existence

3 IDENTIFY RELATIONSHIPS
DATABASE DESIGN IDENTIFY ENTITIES IDENTIFY RELATIONSHIPS CHECK FOR DESIGN PROBLEMS SELECT PRIMARY KEYS CREATE INITIAL RELATIONS APPLY NORMALIZATION PRINCIPLES PRODUCE FINAL DESIGN

4 UML Object-oriented DBS ODL Ideas Relations Relational DBS E-R Database modeling and implementation

5 Entity-Relationship Diagrams
Entity and entity sets An entity set is a collection of distinguishable real-world objects with common properties. An entity is a member of an entity set Students, Instructors, Cars... Attributes An attribute is a data item that describes a property of an entity or a relationship name, registration number, rank….

6 Relationship Relationships are connections among two or more entity sets Multiplicity of E-R Relationships many-to-one many-to-many one-to-one

7 name addr title year movies Stars-in Stars length filmtype Owns Studios E-R schema of movie database name addr

8 Attributes on Relationships

9 E-R DIAGRAM S/W COMPANY SALES PERSON S/W PACKAGES REPRESENTS NAME
PHONE RNO ADDRESS KEY SALES PERSON SSN REGION 1 n ONE-TO-MANY DISTRIBUTES PRICE MANY-TO-MANY m S/W PACKAGES CODE PURPOSE E-R DIAGRAM

10 ONE-TO-MANY RELATIONSHIP
IBM MS BCS HELMES LAURI VERA JAANUS MERIKE JUSTAS S/W COMPANY REPRESENTS SALES PERSON

11 MANY-TO-MANY RELATIONSHIP
IBM MS BCS HELMES OS/2 OFFICE 95 WIN NT OFFICE 97 WIN 95 S/W COMPANY DISTRIBUTES S/W PACKAGES LOTUS NOTES

12 Design Principles Faithfulness
Entity sets and their attributes should reflect reality Whatever connections are asserted should make sense given what we know about the part of the real world being modeled

13 Avoiding Redundancy We should be careful to say everything once only Simplicity Counts Avoid introducing more elements into your design than are absolutely necessary

14 Keys in E-R model We underline the attributes belonging to a key for an entity set (primary key is indicated only) title year movies

15 Relational Database = set of RELATIONS (or TABLES) each with a distinct name Movies, Stars,…. Each relation has a set of ATTRIBUTES (or COLUMNS) with a distinct name within its relation title, year, length, filmtype,...

16 Relational data model is used by most commercial DBS
Oracle, Informix, Sybase, MS Access Relational model is very simple

17 Keys: A key for a relation is a set of attributes such that no two tuples can have the same values for all of their key attributes. In real databases, if there isn't a natural, compact one-attribute key, then keys may be system-generated.

18 Translating E-R design to relations
Assume each entity set has a specified key Translation can be fully automated (except determining keys for generated relations in certain cases)

19 1. Entity set (strong) translates directly to relation
SW Company R-No Name Address Phone R101 IBM Pirita tee R102 Microsoft XYZ R103 BCS Narva mnt R104 Helmes Parnu mnt R106 IE Soft Akadeemia tee

20 E-R Relationships translate to Relations
Corresponding relation has attribute for key attributes of each entity set (E. S.) that participates in relationship if the relationship has attributes, then these are also attributes of corresponding relations renaming attributes is OK (needed if multiple roles in one E. S.

21 2. Binary relationship set between entity sets translates to relation containing keys for entity sets RNO Code Price R101 S R101 S R101 S R101 s R101 S R101 S R102 S R102 S R102 s R103 S R104 S R106 S R106 S Distribution Relationship set with attributes: add attributes to relation for relationship set

22 What is key for relation?
In most general case, key for the relation= all key attributes from all the E.S. involved in relationship however, the relation’s key excludes attributes from the “one” side if relationship is many-one for one-to-one relationship, choose which side provides the key for the relation

23 Combining relations Foreign key Salespersons Common case
relation for an E.S. E plus the relation for some many-one relationship from E to another E.S. Foreign key Salespersons SSN Name Region RNo K10100 Lauri Estonia R104 K10150 Vera Estonia R103 K10200 Jaanus Latvia R104 K10300 Justas Lithuania R102 K10500 Merike Estonia R101 K10600 Marion Latvia R101 K20000 Margus Estonia R102 K Edgars Latvia R106

24 name manuf addr name beers likes drinkers favorite married Example

25 Drinker(name,addr,….favoritebeerName)
beers(name, manuf) likes(DrinkerName,BeerName) married(hasbund,wife)

26 Example:Registration process at CIUE
Financial Information STUDENTS REGISTRAR Student Service Office BANK ACCOUNTANT Account Information Registration Information Special Forms Application 4 REGISTER 3 MANAGE REGISTRATION FORMS 2 SCHEDULE 1 MANAGE BILLS Money Receipts Data Pay Registration Chosen Courses Course data


Download ppt "Hele-Mai Haav: CSC210-Spring*01 CSC230-Spring*03 Database Design."

Similar presentations


Ads by Google