6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and...
-
Upload
martha-horton -
Category
Documents
-
view
221 -
download
6
description
Transcript of 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and...
![Page 1: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/1.jpg)
6-1© Prentice Hall, 2007
Topic 6:Topic 6:Object-Relational ModelingObject-Relational Modeling
Object-Oriented Systems Analysis and Design
Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer
![Page 2: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/2.jpg)
Topic 6 6-2© Prentice Hall, 2007
Chapter ObjectivesChapter Objectives
After studying this chapter you should be able to:– Understand the relational model.– Normalize data to the third normal form.– Understand the object-oriented
extensions to the relational model.
![Page 3: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/3.jpg)
Topic 6 6-3© Prentice Hall, 2007
Chapter Objectives Chapter Objectives (Continued)(Continued)
After studying this chapter you should be able to:– Realize the role of object relations in
systems analysis.– Translate a conceptual data model into
object relations.– Integrate object relations obtained from
different use cases.
![Page 4: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/4.jpg)
Topic 6 6-4© Prentice Hall, 2007
![Page 5: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/5.jpg)
Topic 6 6-5© Prentice Hall, 2007
Object-relational data modeling converts a conceptual data model to a logical data model based on relational and object-oriented technology.
![Page 6: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/6.jpg)
Topic 6 6-6© Prentice Hall, 2007
Purposes of Object-Relational Purposes of Object-Relational ModelingModeling
Produce database structuresCreate entity classesEnhance and finalize the attributes
in the data model
![Page 7: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/7.jpg)
Topic 6 6-7© Prentice Hall, 2007
What Is a Relational Data Model?What Is a Relational Data Model? Based on the concept of relations (tables of data)
Relationships established by matching primary and foreign keys
Relational DBMSs (RDBMS) are the most commonly used in industry today.
Many DBMS vendors have begun adding object-oriented features, creating an object-relational model.
![Page 8: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/8.jpg)
Topic 6 6-8© Prentice Hall, 2007
What Is a Relation?What Is a Relation?A named, two-dimensional table with the
following properties:– All cells contain are atomic (single-value) data.– Entries in columns are from the same set of
values (domain range).– Each row is unique (i.e. has a nonempty
primary key).– Column order does not matter.– Row order does not matter.
This is called First Normal Form (1NF)
![Page 9: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/9.jpg)
Topic 6 6-9© Prentice Hall, 2007
Example relation: note uniqueness of rows guaranteed by Emp_ID. Primary keys are underlined
![Page 10: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/10.jpg)
Topic 6 6-10© Prentice Hall, 2007
What Is Normalization?What Is Normalization?The process of converting complex data
structures into well-structured relations
Well-structured relation – a relation that contains a minimum amount of redundancies and allows rows to be inserted, modified, and deleted without introducing errors or inconsistencies
![Page 11: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/11.jpg)
Topic 6 6-11© Prentice Hall, 2007
Consequences of Relations that Consequences of Relations that Are Not Well StructuredAre Not Well Structured
Insertion anomaly – adding new rows forces user to create duplicate data
Update anomaly – changes in one row force changes in other rows because of duplication
Deletion anomaly – deleting rows may cause a loss of data that would be needed for other future rows
Data integrity requires well-structured relations.
![Page 12: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/12.jpg)
Topic 6 6-12© Prentice Hall, 2007
The Normal FormsThe Normal Forms1st NF – all relations are in 1NF2nd NF – relations with no partial-key
functional dependencies3rd NF – relations with no transitive
functional dependenciesHigher normal forms: 4th, Boyce Codd, 5th –
mainly theoretical, not needed for most OOSAD problems
Main goal is to achieve 3NF for all relations.
![Page 13: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/13.jpg)
Topic 6 6-13© Prentice Hall, 2007
What Is a Functional What Is a Functional Dependency?Dependency?
The functional dependency of attribute B on attribute A is represented by an arrow A B, and implies that every valid value of attribute A uniquely determines the value of attribute B.
Determinant – the attribute on the left side of the arrow
All primary keys are determinants
![Page 14: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/14.jpg)
Topic 6 6-14© Prentice Hall, 2007
Second Normal Form (2NF)Second Normal Form (2NF)
1NF, plus no partial key functional dependencies
If the primary key is a composite key (composed of more than one attribute) it is possible for an attribute to be functionally dependent on only part of the key
Avoid partial dependencies for 2NF
![Page 15: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/15.jpg)
Topic 6 6-15© Prentice Hall, 2007
This table has a composite key (Emp_ID and Course)
Functional dependencies:Emp_ID Name, Dept, SalaryEmp_ID, Course Date_Completed
Name, Dept, and Salary all have partial key dependencies, causing duplication of data.
![Page 16: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/16.jpg)
Topic 6 6-16© Prentice Hall, 2007
Solution:
Break the relation into two separate relations.
1:N relationship linked by Emp_ID
No partial key dependencies
Well structured
![Page 17: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/17.jpg)
Topic 6 6-17© Prentice Hall, 2007
Third Normal Form (3NF)Third Normal Form (3NF)2NF, plus no transitive functional
dependencies
Given three attributes in a relation A, B, C, if A B and B C, this forms a transitive functional dependency
Avoid transitive dependencies for 3NF
![Page 18: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/18.jpg)
Topic 6 6-18© Prentice Hall, 2007
Here, Customer_ID Salesperson, and Salesperson Region, cause a transitive dependency
![Page 19: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/19.jpg)
Topic 6 6-19© Prentice Hall, 2007
Break the relation into two separate relations.
1:N relationship linked by SalesPerson
No transitive dependencies
Well structured
Solution:
![Page 20: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/20.jpg)
Topic 6 6-20© Prentice Hall, 2007
Primary and Foreign KeysPrimary and Foreign Keys Primary key – one or more attributes that together
form a unique identifier for rows in the relation
Foreign key – an attribute that appears as a non-primary key attribute or as part of a primary key in one relation and as a primary key attribute in another relation
Relationship – rows in one relation are matched with related rows in another relation through foreign keys
![Page 21: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/21.jpg)
Topic 6 6-21© Prentice Hall, 2007
Referential IntegrityReferential IntegrityA rule that states that any foreign key value
(on the relation of the many side) MUST match a primary key value in the relation of the one side
No foreign key can contain a value that is not present in a primary key in the other relation
![Page 22: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/22.jpg)
Topic 6 6-22© Prentice Hall, 2007
Object-Oriented Extensions to Object-Oriented Extensions to Relational ModelingRelational Modeling
– Generalization– Multivalued attributes (OK to violate atomicity
requirement of 1NF)– Aggregation– Object identifiers– Pointers– Behaviors– Richer set of data types
Object-relational Data Model
![Page 23: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/23.jpg)
Topic 6 6-23© Prentice Hall, 2007
Translating Conceptual Data Translating Conceptual Data Model to Object-Relational ModelModel to Object-Relational Model
Translate classesTranslate relationshipsNormalize object relationsMerge object relations
![Page 24: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/24.jpg)
Topic 6 6-24© Prentice Hall, 2007
Relational approach, forces atomic attributes
Object-relational approach, with multivalued attribute
Comparison of techniques for translating multivalued attributes
![Page 25: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/25.jpg)
Topic 6 6-25© Prentice Hall, 2007
When constructing 1:N relationships, the foreign key is added as an attribute to the relation on the N side.
![Page 26: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/26.jpg)
Topic 6 6-26© Prentice Hall, 2007
Associative class and M:N relationship
![Page 27: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/27.jpg)
Topic 6 6-27© Prentice Hall, 2007
Points for Figure 8.11Points for Figure 8.11Associative class is translated into a relation
whose primary key is a composite of the primary keys of the other two classes.
M:N relationship between Work and Skill is implemented as an extra relation UseSkills, whose primary key is composed of the primary keys of Work and Skill.
![Page 28: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/28.jpg)
Topic 6 6-28© Prentice Hall, 2007
Unary 1:N relationship is represented by a foreign key managerID, which matches with the empId primary key of the same relation.
![Page 29: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/29.jpg)
Topic 6 6-29© Prentice Hall, 2007
Unary M:N relationship is represented by a separate relation Prerequisite, whose primary key is composed of two primary key values from the Course relation.
![Page 30: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/30.jpg)
Topic 6 6-30© Prentice Hall, 2007
Other RelationshipsOther RelationshipsAggregation and Composition – use same
rules that apply to association. Composition is 1:N, aggregation is M:N
Generalization – no uniform standard exists. Can make use of stereotypes to annotate generalizations
![Page 31: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/31.jpg)
Topic 6 6-31© Prentice Hall, 2007
Merging Object RelationshipsMerging Object RelationshipsSimilar or redundant object relations can be
merged into oneExample:
merge
![Page 32: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/32.jpg)
Topic 6 6-32© Prentice Hall, 2007
Problems with MergingProblems with Merging Synonyms – two relations with different attribute
names referring to same meaning– Solution – decide on a single standard name
Homonyms – two relations with same attribute names referring to different meanings– Solution – create new attribute for second meaning
Dependencies between non-key attributes after merge– Solution – normalize the merged relation
![Page 33: 6-1 Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,](https://reader036.fdocuments.in/reader036/viewer/2022062306/5a4d1b7a7f8b9ab0599b8cd1/html5/thumbnails/33.jpg)
Topic 6 6-33© Prentice Hall, 2007
RecapRecap After studying this chapter we learned to:
– Understand relational and object-relational models.
– Normalize data.– Understand role of object-relations.– Translate conceptual data models to object
relations.– Integrate object relations.