Presentation is loading. Please wait.

Presentation is loading. Please wait.

IE 423 – Design of Decision Support Systems Data modeling and database development.

Similar presentations


Presentation on theme: "IE 423 – Design of Decision Support Systems Data modeling and database development."— Presentation transcript:

1 IE 423 – Design of Decision Support Systems Data modeling and database development

2 Important Dates to Remember 0 days – Leap Day 3 days – Midterm Exam – March 3 rd 17 days – St. Patrick’s Day 19 days – DSS Analysis Report Due 22 days – Spring Break

3 By now you should have Read Chapters 1,2,3 and 4 in Pol and Ahuja Also, read chapter 5 in Pol and Ahuja

4 Data Modeling Now that you have explored the creation of Object models and Entity- Relation models… The next steps is to create relational data models

5 Data Modeling Relational Data Models Idea developed by E. F. Codd from IBM (published in 1970) Based on the idea of relational algebra Three major components Relational Data Structure (entities, attributes, relationships) Data Manipulation – methods, language, etc. manipulating data –Relational Data Integrity – Rules to insure structural and data integrity is maintained

6 Data Modeling Relational Data Structure – Relation is a is a 2 dimensional grid like data structure (rows and columns) Relation is the set of attributes “defining” an entity (columns)… …by a variable number of entity instances (rows) Notation for a relation  Student(ID, Name, Rank, Email, Major)  Number of attributes (columns)= Degree of Relation  Number of instances (rows) = Cardinality of Relation Above notation referred to as Relational Schema

7 Data Modeling Properties of a Relation Each relation has a unique name Each attribute of an instance (row) is a simple (atomic) value Each record is unique Each attribute has a distinct name All values of a given attribute must be from the same domain Order of attributes not important Order of instances (rows) not important

8 Data Modeling E-R Diagram Rectangle = relation Ellipses = attributes Student ID Name Rank Major

9 Data Modeling Data manipulation Method and procedures for manipulating data in relations  Usually a language  Can be done with GUI controls  Usually still a language  Structured Query Language – SQL SELECT ID, Name, Rank FROM Student WHERE Rank = Senior

10 Data Modeling Relational Data Integrity Constraints Basically rule to assure that relations and relationships are properly maintained as data is manipulated Probably the one you will hear most is  Referential Integrity

11 Data Modeling Keys Remember that each instance must be unique You must have one or more attributes that make the instance unique Relational Keys

12 Data Modeling Keys Super Keys = Any set of one or more attributes that will make an instance unique  Student(ID, Name, Email)  Student(ID)  Student(Email) Candidate Key = the simpliest super key, may be more than one  Student(ID)  Student(Email)

13 Data Modeling Keys Primary Key – a candidate key selected to uniquely identify each instance (record) Primary Key can never have a Null value Cannot change values of Primary Key  Bad Primary Keys Student(LastName) Student(Email)  Probably good Student(ID)

14 Data Modeling Keys Foreign Keys – in a relationship (multiple relations) an attribute in one entity that is a Primary key in the other entity, Or is the primary key in the same relation (we’ll come back to this) Attribute must be in common in both entities in the relationship Foreign keys do not need to be unique  Student(ID, Name, Rank, Major)  Majors(MajorCode, MajorTitle) (Foreign key= MajorCode) There are some important ideas about Foreign Keys

15 Data Modeling Data Integrity Constraints Domain constraints  All values of a given attribute must be from the same domain Entity Constraints  Every relation must have a primary key  Primary key must be unique  Primary key cannot have a Null value Referential Constraints  Insures relationship between Primary and Foreign keys  Values of foreign keys must come from the primary key in related relation…  …or foreign key may Null

16 Data Modeling Translate E-R model to Relational Schema Task 1: translate regular entities to schema Translate entity in E-R model to relation Assign entity name as relation name Each simple attribute in entity= attribute in relation Unique identifier of entity = primary key of relation

17 Data Modeling Task 1: translate regular entities to schema Student ID Name Rank Major Student(ID, Name, Rank, Major) Student IDNameRankMajor

18 Data Modeling Task 2:translate composite attributes to simple attributes Student(ID, Name, Rank, Address) == Student(ID, Name, Rank, Street, City, State,…)

19 Data Modeling Task 2:translate composite attributes to simple attributes Student(ID, Name, Rank, Major, Address) == Student(ID, Name, Rank, Major, Street, City, State,…) Student IDNameRankMajorStreetCityStateZip Student IDNameRankMajorAddress

20 Data Modeling Task 3: Transform multivalue attributes Create relation for entity Do not include multivalue attribute in relation Create another relation to represent the multivalue attribute  Each value of the multivalue attribute is an instance (record) in new relation  Make relation between new relation and original relation  Make foreign key in new relation that is equal to primary key of original instance

21 Data Modeling Task 3: Transform multivalue attributes Create relation for entity Do not include multivalue attribute in relation Create another relation to represent the multivalue attribute  Each value of the multivalue attribute is an instance (record) in new relation  Make relation between new relation and original relation  Make foreign key in new relation that is equal to primary key of original instance

22 Data Modeling Task 3: Transform multivalue attributes Applicants(Name, ID, Skills(skill,skill,…) -> Applicants(Name, ID) + Skills(ID, Skill) (ID = foreign key) Applicants NameID Skills IDSkill

23 Data Modeling Task 4: Transforming Unary Relationships Remember: unary relationships involve only one entity, therefore, one relation Three types of unary relationships  No relationship – simple relation – task 1-3 (3*)  One-to-One relationship  One-to-Many relationship

24 Data Modeling Task 4: Transforming Unary Relationships One-to-One – do task 1-3 (3*) Create one relation Add an attribute that will be a foreign key  Matches primary key in same relation  Each instance will unique value in foreign key DormResidents NameRoomNoID DormResidents NameRoomNoIDRoommate

25 Data Modeling Task 4: Transforming Unary Relationships One-to-Many – do task 1-3 (3*) Create one relation Add an attribute that will be a foreign key  Matches primary key in same relation  Each instance will unique value in foreign key DormResidents NameRoomNoID DormResidents NameRoomNoIDRA

26 Data Modeling Task 5: Transforming Binary Relationships Remember: binary relationships involve two entities, therefore, two relations Three types of binary relationships  One-to-One relationship  One-to-Many relationship  Many-to_Many relationship

27 Data Modeling Task 5: Transforming Binary Relationships One-to-One relationship – one instance in one relation matches one instance in the other relation Tasks 1-3 for each entity/relation Define relationship  Link primary key in one relation to primary key other relation StudentInfo(ID, Name, Rank, Major) + StudentContact(ID, email, phone, AddrStreet,…) Relationship based on ID (common in both relations) ID is primary key in both relations

28 Data Modeling Task 5: Transforming Binary Relationships One-to-Many relationship – one instance in one relation matches multiple instances in the other relation Tasks 1-3 for each entity/relation Define relationship  Link primary key in one relation to primary key other relation Dorm(DormID, DormName, MainPhone) + StudentInfo(ID, Name, DormID) Relationship based on DormID (common in both relations) DormID is foreign key in StudentInfo relation but but primary key in Dorm relation

29 Data Modeling Task 5: Transforming Binary Relationships One-to-Many relationship – one instance in one relation matches multiple instances in the other relation Tasks 1-3 for each entity/relation Define relationship  Link primary key in one relation to primary key other relation Dorm(DormID, DormName, MainPhone) + StudentInfo(ID, Name, DormID) Relationship based on ID (common in both relations) DormID is foreign key in StudentInfo relation but but primary key in Dorm relation

30 Data Modeling Task 5: Transforming Binary Relationships Many-to-Many relationship – multiple instances in one relation matches multiple instances in the other relation Consider a class registration system - you have multiple students that can multiple classes and you have multiple classes each which may have multiple students Given these two relations  Student(StudentID, Name, Rank, Major)  Course(CourseID, Name, CRN, Instructor) So how do you create a binary relationship between these two relations? You can’t!

31 Data Modeling Task 5: Transforming Binary Relationships Many-to-Many relationship – multiple instances in one relation matches multiple instances in the other relation You have to convert it to a ternary relationship What’s a ternary relationship? Involves three entity/relations Where does the third entity come from?

32 Data Modeling Task 5: Transforming Binary Relationships Answer: you create it! Add a third relation This relation has three attributes (can have more)  A unique identifier for each instance in new relation (primary key)  A foreign key to link the instance to an instance in relation A  A foreign key to link the instance to an instance in relation B

33 Data Modeling Task 5: Transforming Binary Relationships Here’s the problem Course CourseIDNameCRNInstructor Students StudentIDNameRankMajor Relationship? Think about this!

34 Data Modeling Task 5: Transforming Binary Relationships Here’s the solution Course CourseIDNameCRNInstructor Students StudentIDNameRankMajor Registrations RegistIDStudentIDCourseID

35


Download ppt "IE 423 – Design of Decision Support Systems Data modeling and database development."

Similar presentations


Ads by Google