Title: ObjectOriented Analysis
1Object-OrientedAnalysis Design
2Databases and DBMSs
- Databases are integrated collections of stored
data that are centrally managed and controlled - Described by a schema
- DBMSs are system software components that manage
and control access to a database
3Components of a DB and DBMS
4DBMS Important capabilities
- Simultaneous access by multiple users and
applications - Access to data without application programs
- Managing organizational data
5Database Models
- Impacted by technology changes
- Model Types
- Hierarchical
- Network
- Relational
- Object-oriented
- Current systems generally use relational or
object-oriented data models
6Relational Databases
- The relational database management system
organizes data into tables or relations - Tables
- Tuples rows or records
- Fields columns or attributes
- Tables have key field(s) which can be used to
identify unique records - Keys relate tables to each other
7Entity Relationship Diagram
8Partial Relational Database Table
9Designing Relational Databases
- Create table for each entity type
- Choose or invent primary key for each table
- Add foreign keys to represent one-to-many
relationships - Create new tables to represent many-to-many
relationships - Define referential integrity constraints
- Evaluate schema quality and make necessary
improvements - Choose appropriate data types and value
restrictions (if necessary) for each field
10Enforcing Referential Integrity
- Consistent relational database state
- Every foreign key also exists as a primary key
value - DBMS enforces referential integrity automatically
once schema designer identifies primary and
foreign keys
11Automatic Enforcement for Referential Integrity
- When rows containing foreign keys are created,
DBMS ensures that the value also exists as a
primary key in related table - When row is deleted, DBMS ensures no foreign key
in related tables have the same value as primary
key of deleted row - When primary key value is changed, DBMS ensures
no foreign key values in related tables contain
the same value
12Evaluating Schema Quality
- High quality features
- Uniqueness of table rows and primary keys
- Ease of implementing future data model changes
(flexibility and maintainability) - Lack of redundant data
- Is Design judgment-based?
13Database Normalization
- Ensure database quality by minimizing data
redundancy - Normal forms
- 1NF - no repeating fields or groups of fields
- Functional dependency - one-to-one relationship
between the values of two fields - 2NF - in 1NF and if each non-key element is
functionally dependent on entire primary key - 3NF - in 2NF and if no non-key element is
functionally dependent on any other non-key
element
14Decomposition of 1NF Table into 2NF Tables
15Conversion of 2NF Table into 3NF Tables
16Object-Oriented Databases
- Direct extension of the OO design and programming
paradigm - ODBMS stores data as objects or classes
- Object definition language (ODL)
- Standard language for describing structure and
content of an object database
17Designing Object Databases
- Determine which classes require persistent
storage - Define persistent classes
- Represent relationships among persistent classes
- Choose appropriate data types and value
restrictions (if necessary) for each field.
18Representing Classes
- Transient
- Exist only during lifetime of program or process
- Examples view window, pop-up menu
- Persistent
- Not destroyed when program or process ceases
execution - Exist independently of program
- Examples customer information, employee
information
19Representing Relationships
- Object identifiers
- Used to identify objects uniquely
- Physical storage address or reference
- Relate objects of one class to another
- ODBMS uses attributes containing object
identifiers to find objects that are related to
other objects
20Representing Relationships (cont.)
- Keyword relationship can be used to declare
relationships between classes - Advantages include
- ODBMS assumes responsibility for determining
connection - ODBMS assumes responsibility for maintaining
referential integrity - Type of relationships
- 11, 1M, MM
- Association class used with MM
2111 Relationship Represented with Attributes
Containing Object Identifiers
attributes shown in color
221M Relationship Between Customer and Order
Classes
231M with Attributes Containing Object Identifiers
24MM Relationship between Employee and Project
Classes
25MM Relationship Represented with two 1M
Relationships
26Generalization Hierarchy
27Hybrid Object-Relational Database Design
- Relational database management system used to
store object attributes and relationships - Two design tasks
- Developing complete relational schema
- Developing equivalent set of classes
- Problems
- Programmer defined method storage and execution
- Relationships are restricted
- ERDs cannot represent methods
28Relationships and Inheritance in Hybrid Design
- Relationships must be represented with foreign
keys - Inheritance
- Combine all tables into a single table containing
a superset of all class attributes but excluding
all invented fields from child classes - Use separate tables to represent child classes
and substitute the primary key of the parent for
the invented keys of the child
29Data Types
- Storage format and allowable content of a program
variable - Primitive data types
- Pointer, Boolean, integer, etc.
- Complex data types
- Dates, times, audio streams, video images
- User-Defined data types
30Object DBMS Data Types
- Comparable to RDBMS data types
- Schema designer can create new data types and
associated constraints - Classes are complex user-defined data types that
contain methods to manipulate data