Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SOFTWARE DESIGN
Data Management Design
Objectives
The different ways of storing persistent objects
The differences between object and relational databases
How to design data management objects
Persistence
Some objects are transient, exist in memory and are
discarded when an application terminates
Some objects must exist from one execution of an
application to another or be shared among different
instances of applications. Such objects are persistent
objects (persistent data)
Storage of Persistent Data or Objects
Persistent data or objects may be stored in
files
for storing data which is transferred to or from other systems
configuration information
database management systems (DBMS)
relational DBMS hold tables of data
object DBMS hold objects and links
the choice of DBMS will have an impact on the amount of work required
of the system designers
Persistence Design Questions
Can files be used for some storage?
Is it truly an O-O system or just an interface to a relational
database using Java or C++?
Will the system use an existing DBMS?
Will it use a relational DBMS?
Will it use an object DBMS?
Persistence Design Questions
What is the logical layering of the system?
What is the physical layering of the system?
Is the system distributed? Does this include distributed
data storage?
What protocols will be used to communicate within the
system?
File Systems
Files and record structures
Fixed length (padded)
Variable length (delimited)
Header and detail
Tagged data (XML)
<author>
<forename>Simon</forename>
<surname>Bennett</surname>
</author>
File Systems
File organization
Serialnew records appended
Sequentialrecords ordered in file, usually according to a
numeric key
Randomuses an algorithm to convert a key to an
address in the file
File Systems
File access methods
Serialto read serial and sequential files
Index-sequentialusing indexes to find records
in a sequential file and improve access time
Directusing relative or hashed addressing to
move directly to the required record in the file
Searching for Hamer using index-sequential file access
Direct Access
Database Management
Systems (DBMS)
Problems with files:
redundancynumber of files grows with applications,
and data is duplicated
inconsistencydata is updated in one applications
files, but not in anothers
maintenance problemschanges to data structures
mean changes to many programs
difficulty combining databusiness needs may mean
users want data from different applications
DBMS Schema
Ultimately data in databases is stored in files, but their
structure is hidden from developers
locationsList[1]:Location locationsList[1]:Location
locationCode = NY locationCode = NY
locationName = New York locationName = New York
locationMgr = Martina Duarte locationMgr = Martina Duarte
locationMgrTel = ext. 312 locationMgrTel = ext. 312
locationsList[2]:Location
locationCode = TO
locationName = Toronto
locationMgr = Pierre Dubois
locationMgrTel = ext. 37
Designing for Relational Database
Management Systems
If an RDBMS is used to provide storage for an OO
system, it is necessary to flatten the classes into tables
complex objects must be taken apart and the parts stored in
different tables
when the system requires an object, the data must be retrieved
from the tables which hold parts of that object so that it can be
reconstructed
Two approaches can be used to convert classes to tables
normalisation
a series of rules of thumb
Normalisation
Normalisation is based on the idea of functional
dependency
for two attributes A and B, A is functionally dependent
on B if for every value of B there is exactly one value of
A associated with it at any given time: B A
There are five normal forms of normalised data
the data is free of redundancy in fifth normal form
for practical purposes it is usually adequate to
normalise data into third normal
Normalisation
Data from complex structures is flattened into tables
Typically normalization is carried out as far as Third
Normal Form
In an object-oriented system, we may use normalization
to convert classes to table schemas
Normalization Example
ic1:InternationalCampaign ic2:InternationalCampaign
locationsList[1]:Location locationsList[1]:Location
locationCode = NY locationCode = NY
locationName = New York locationName = New York
locationMgr = Martina Duarte locationMgr = Martina Duarte
locationMgrTel = ext. 312 locationMgrTel = ext. 312
locationsList[2]:Location
locationCode = TO
locationName = Toronto
locationMgr = Pierre Dubois
locationMgrTel = ext. 37
Objects as a Table