Data Management Layer Design
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright 2009 John Wiley & Sons, Inc. All rights reserved.
Objectives
Become familiar with several object-persistence formats. Be able to map problem domain objects to different objectpersistence formats. Be able to apply the steps of normalisation to a relational database. Be able to optimise a relational database for object storage and access. Become familiar with indexes for relational databases. Be able to estimate the size of a relational database. Be able to design the data access and manipulation classes.
17 March, 2011 ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material. 2
The Data Management Layer
Includes:
data access and data manipulation logic the actual design of the storage
Four-step design approach
Select the format of the storage Map the problem-domain objects to an objectpersistence format optimise the object-persistence format design the data access and manipulation classes
17 March, 2011 ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material. 3
OBJECT PERSISTENCE FORMATS
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright 2009 John Wiley & Sons, Inc. All rights reserved.
Object Persistence Formats
Files (Sequential and Random) Relational databases Object-relational databases Object-oriented databases
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
Sample File
Fictitious customer database
17 March, 2011 ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material. 6
Sequential & Random Access Files
Read, write, and search
Sequential access files allow sequential operations (assumes disc storage) Efficient for report writing Searches are not efficient because on average 50% of records have to be accessed Two versions
Ordered (linked list) Unordered (chronological placement)
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
Random Access Files
Allow only random or direct file operations Good for finding and updating a specific object Inefficient for report writing Require a key or index to locate the desired record
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
Application File Types
Master Files Look-up or Reference files Transaction files or Journals Audit file History file
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
Relational Databases
Collection of tables
A table is comprised of rows of attributes that define an entity Each row in the table is a unique record The same attribute in each record is the primary key of the table. Each key value must be unique
Tables are related to each other
A foreign key is a record attribute that is the primary key of another table Relationships established by linking foreign key of one table to the primary key of another table
17 March, 2011 ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material. 10
Database Management System - DBMS
Software that creates and manipulates a database RDBMS is a DBMS for a relational database RDBMS usually support Referential Integrity
the idea of ensuring that values linking the tables together (references) through the primary and foreign keys are valid and correctly synchronised
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
11
Referential Integrity Example
The class Customer has an attribute custID The class Order has an attribute custID that indicates the customer who placed the order You should not be able to:
create an order for a non-existent Customer; delete a Customer who has existing orders; change the custID value of a Customer, unless you also change the custID values of the related orders (caveat never change primary keys)
17 March, 2011 ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material. 12
The Structured Query Language: SQL
A standard language for manipulating data in tables: DDL and DML SQL Commands enable the functions:
Create, edit, and delete tables Add, edit, and delete data Display data from one or more related tables Display data computed from data in one or more related tables
Studied in ICT118 Database and Info Retrieval
17 March, 2011 ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material. 13
Selecting Persistence Formats
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
14
MAPPING PROBLEM-DOMAIN OBJECTS TO OBJECTPERSISTENCE FORMATS
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright 2009 John Wiley & Sons, Inc. All rights reserved.
Mapping PD Classes to RDBMS
Map all concrete problem domain classes to the RDBMS tables. Map single valued attributes to columns of the tables. Map methods to stored procedures or to program modules. Map single-valued aggregation and association relationships to a column that can store the key of the related table Map multi-valued attributes and repeating groups to new tables and create a one-to-many association from the original table to the new ones.
17 March, 2011 ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material. 16
Mapping PD Classes to RDBMS
Map multi-valued aggregation and association relationships to a new associative table that relates the two original tables together. Copy the primary key from both original tables to the new associative table For aggregation and association relationships of mixed type, copy the primary key from the single-valued side (1..1 or 0..1) of the relationship to a new column in the table on the multi-valued side (1..* or 0..*) of the relationship that can store the key of the related table Ensure that the primary key of the subclass instance is the same as the primary key of the superclass..
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
17
OPTIMISING RDBMS-BASED OBJECT STORAGE
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition
Copyright 2009 John Wiley & Sons, Inc. All rights reserved.
Optimising Storage Efficiency
No redundant data: Wastes space an issue in large scale information system Allows more opportunities for error Few null values in tables: Null is difficult to interpret
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
19
Normalisation
Tells us how well-formed the data is in an RDBMS Reduces data redundancies First four levels of normalisation are
1 Normal Form: removes multi-valued fields 2 Normal Form: removes partial-key dependencies 3 Normal Form: removes transitive dependencies (dependence on non-primary key fields) Boyce-Codd Normal Form: every determinant is a candidate key Analysis & Design. Semester 2, 2010. 17 March, 2011 ICT117 Systems 20
Includes John Wiley & Sons material.
Steps of Normalisation
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
21
Next lecture
HCI Human Computer Interface design
17 March, 2011
ICT117 Systems Analysis & Design. Semester 2, 2010. Includes John Wiley & Sons material.
22