Download presentation
Presentation is loading. Please wait.
Published byMaximilian Riley Modified over 9 years ago
1
Database Design Some of these slides are derived from IBM/Rational slides from courses on UML and object-oriented design and analysis. Copyright to the original slides resides with IBM/Rational. They are used here, in this course, under password protection limited to students enrolled in the course, with permission of the owners, but are not to be published or further distributed. Other slides are derived from Dennis, Wixom & Tegarden Systems Analysis & Design with UML, 3 rd edition, copyright John Wiley & Sons, used under similar permissions.
2
Objectives: Database Design Define the purpose of Database Design and where in the lifecycle it is performed Explain how persistent classes map to the data model Learn how to distribute class behavior to the database
3
Database Design in Context [Early Elaboration Iteration] [Inception Iteration (Optional)] Define a Candidate Architecture Perform Architectural Synthesis Analyze Behavior Refine the Architecture Design Components Design the Database (Optional) Database Design Database Designer
4
Database Design Overview Supplementary Specifications Database Design Use-Case Realization Project Specific Guidelines Analysis Classes Design Classes Design ModelData Model
5
Database Design Steps Map persistent design classes to the data model Distribute class behavior to the database
6
Database Design Steps Map persistent design classes to the data model Distribute class behavior to the database
7
Not entirely compatible – RDBMS Focus is on data Better suited for ad-hoc relationships and reporting application Expose data (column values) – Object Oriented system Focus is on behavior Better suited to handle state-specific behavior where data is secondary Hide data (encapsulation) Relational Databases & Object Orientation
8
The Relational Data Model Relational model is composed of – Entities – Attributes – Relations ORDERLINE ITEM PRODUCT Order_Id LineItem_Id Description Price Quantity Product_Id Order_Id Product_Id Name Price lineItem order products lineItems Entity Relation Columns (aka Attributes) An ERD diagramAn ERD diagram
9
The Object Model The Object Model is composed of – Classes – Attributes – Associations LineItem - quantity : Integer - number : Integer 1..* +lineItems Order - number : Integer +order Product - number : Integer - description : String - unitPrice : Double 1 Software Product - version : Double Hardware Product - assembly : String A class diagram
10
Persistence Frameworks Challenge: – Changes should not break the model Solution: an object-relational framework that – Encapsulates the physical data store – Provides object translation services Importance of the framework – 30% of development time is spent in accessing an RDBMS – Maintenance can be 60% of total cost Business Object Model Relational Database Compact interfaces Object-relational translation Encapsulates data store
11
Object-Relational Framework: Characteristics Performance – Decomposing objects to data – Composing objects from data Minimize design compromises – Limit changes to object and relational models Make it extensible – 15%-35% of the application will require extensions to the framework
12
Object-Relational Frameworks: Characteristics (continued) Documentation of the API Documentation of internals, for extension Support for common object-relational mappings Persistence interfaces – Examples are save, delete, and find
13
Common Object-Relational Services Patterns are beginning to emerge for object-relational applications – CORBA Services specification Persistence Query - e.g., “find”, “find unique” Transactions Concurrency Relationships Refer to the appropriate CORBA specifications for further details.
14
Student - name : String - address : String - studentID : Long Mapping Persistent Classes to Tables In a relational database – Every row is regarded as an object – A column in a table is equivalent to a persistent attribute of a class NameAddressStudent_ID Thomas Stuart987 High St.123456 Object Instance Attributes from object type
15
Mapping Associations Between Persistent Objects Associations between two persistent objects are realized as foreign keys to the associated objects. – A foreign key is a column in one table that contains the primary key value of associated object NumberCourse_ID 678456789 NameDescriptionNumber Math 101Algebra456789 Course Offering table Course table Course - name - description - number CourseOffering - number : String 0..* 1 Primary Key Foreign Key
16
Mapping Aggregation to the Data Model Aggregation is also modeled using foreign key relationships – The use of composition implements a cascading delete constraint Student. - studentID : int Schedule - semester : Semester 0..* 1 Student_IDSemester 123456Spring 2001 Schedule table Student_ID 123456 Foreign Key Primary Key Student table
17
Modeling Inheritance in the Data Model A Data Model does not support modeling inheritance in a direct way Two options: – Use separate tables (normalized data) – Duplicate all inherited associations and attributes (de-normalized data)
18
Database Design Steps Map persistent design classes to the data model Distribute class behavior to the database
19
What Are Stored Procedures? A stored procedure is executable code that runs under the RDBMS Two types of stored procedures: – Procedures: Executed explicitly by an application – Triggers: Invoked implicitly when some database event occurs
20
Map Class Behavior to Stored Procedures Determine if any operations can be implemented as a stored procedure Candidates: – Operations that deal with persistent data – Operations in which a query is involved in a computation – Operations that need to access the database to validate data
21
Example: Map Class Behavior to Stored Procedures Student. + getTuition() + addSchedule() + getSchedule() + deleteSchedule() + hasPrerequisites() # passed() + getNextAvailID() + getStudentID() + getName() + getAddress() ClassCandidate Operations getTuition addSchedule getSchedule deleteSchedule getStudentID getName getAddress
22
Checkpoints: Database Design Have all persistent classes been mapped to database structures? Have stored procedures and triggers been defined? Does the persistence mechanism use stored procedures and database triggers consistently?
23
Review: Database Design What is the purpose of the Database Design? What comprises a relational data model? What are the components of an object model? When mapping persistent classes to tables, what is every row in a table regarded as? What is every column equivalent to? What are stored procedures?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.