INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

77
INFORMATION SYSTEMS @ X INFORMATION SYSTEMS @ X INFO425: Systems Design INFO425: Systems Design Chapter 13 Chapter 13 Database Design Database Design

Transcript of INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

Page 1: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

INFO425: Systems DesignINFO425: Systems Design

Chapter 13Chapter 13

Database DesignDatabase Design

Page 2: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Learning ObjectivesLearning Objectives

Describe the differences and similarities between Describe the differences and similarities between relational and object-oriented database management relational and object-oriented database management systemssystems

Design a relational database schema based on an Design a relational database schema based on an entity-relationship diagramentity-relationship diagram

High LevelHigh Level

DetailedDetailed

Design an object database schema based on a class Design an object database schema based on a class diagramdiagram

Page 3: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Learning Objectives (Learning Objectives (continuedcontinued))

Design a relational schema to implement a hybrid Design a relational schema to implement a hybrid object-relational databaseobject-relational database

Describe the different architectural models for Describe the different architectural models for distributed databasesdistributed databases

Page 4: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

OverviewOverview

This chapter describes design of relational and OO This chapter describes design of relational and OO data models data models

Developers transform conceptual data models into Developers transform conceptual data models into detailed database models detailed database models

Entity-relationship diagrams (ERDs) for traditional analysisEntity-relationship diagrams (ERDs) for traditional analysis Class diagrams for object-oriented (OO) analysisClass diagrams for object-oriented (OO) analysis

Detailed database models are implemented with Detailed database models are implemented with database management system (DBMS)database management system (DBMS)

Page 5: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Databases and Database Databases and Database Management SystemsManagement Systems

Databases (DB) Databases (DB) – integrated collections of stored – integrated collections of stored data that are centrally managed and controlleddata that are centrally managed and controlled

Database management system (DBMS)Database management system (DBMS) – system – system software that manages and controls access to software that manages and controls access to databasedatabase

Databases described by a Databases described by a schemaschema – description of – description of structure, content, and access controlsstructure, content, and access controls

XML: Data and Schema are integrated XML: Data and Schema are integrated

Page 6: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

XML ExampleXML Example

ElementsElements

<PROPERTYLIST><PROPERTYLIST>

<PROPERTY><PROPERTY>

<PROPERTYNO>PA14</PROPERTYNO><PROPERTYNO>PA14</PROPERTYNO>

<ADDRESS><ADDRESS>

<STREET>16 Holland</STREET><STREET>16 Holland</STREET>

<CITY>Aberdeen</CITY><CITY>Aberdeen</CITY>

<POSTCODE>AB7 5SU</POSTCODE><POSTCODE>AB7 5SU</POSTCODE>

</ADDRESS></ADDRESS>

<RENT>650</RENT><RENT>650</RENT>

</PROPERTY></PROPERTY>

</PROPERTYLIST> </PROPERTYLIST>

Page 7: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Database ModelsDatabase Models

Impacted by technology changes since 1960sImpacted by technology changes since 1960s Model typesModel types

Hierarchical Hierarchical NetworkNetwork RelationalRelational Object-orientedObject-oriented

Most current systems use relational and (rarely) Most current systems use relational and (rarely) object-oriented data modelsobject-oriented data models

Page 8: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Page 9: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Network Data ModelNetwork Data Model

Page 10: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Relational Data ModelRelational Data Model

Page 11: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Multidimensional Data ModelMultidimensional Data Model

Page 12: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ XObject Oriented Data ModelObject Oriented Data Model

Page 13: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Components of a DB and DBMS Components of a DB and DBMS

Virtually all actions in a Virtually all actions in a relational DB managed relational DB managed

through Structured Query through Structured Query LanguageLanguage

Page 14: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Important DBMS CapabilitiesImportant DBMS Capabilities

Simultaneous access by multiple users and Simultaneous access by multiple users and applicationsapplications

Access to data without application programs (via a Access to data without application programs (via a query language)query language)

Organizational data management with uniform Organizational data management with uniform access and content controlsaccess and content controls

Page 15: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Objectives of SQLObjectives of SQL

Ideally, database language should allow user to:Ideally, database language should allow user to: create the database and relation structures; create the database and relation structures; perform insertion, modification, deletion of data; perform insertion, modification, deletion of data; perform simple and complex queries.perform simple and complex queries.

Should perform these tasks with minimal user effort and Should perform these tasks with minimal user effort and command structure/syntax must be easy to learn. command structure/syntax must be easy to learn.

Should be portable.Should be portable. The relational model provides Structured Query Language The relational model provides Structured Query Language

(SQL) to meet the above objectives(SQL) to meet the above objectives

Page 16: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

SQL BenefitsSQL Benefits

SQL is relatively easy to learn:SQL is relatively easy to learn:

it is non-procedural - you specify it is non-procedural - you specify whatwhat information you require, rather information you require, rather than than howhow to get it; to get it;

it is essentially free-format.it is essentially free-format.

Relatively easy to learn and use – but also very powerfulRelatively easy to learn and use – but also very powerful Consists of standard English words:Consists of standard English words:

CREATE TABLE Staff(staffNo VARCHAR(5), CREATE TABLE Staff(staffNo VARCHAR(5),

lName VARCHAR(15), lName VARCHAR(15), salary DECIMAL(7,2));salary DECIMAL(7,2));

INSERT INTO Staff VALUES ('SG16', 'Brown', 8300);INSERT INTO Staff VALUES ('SG16', 'Brown', 8300);

Page 17: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

SQLSQL

SQL has 3 major components:SQL has 3 major components:

A Data Definition Language (DDL) for defining database A Data Definition Language (DDL) for defining database structure.structure.

A Data Manipulation Language (DML) for retrieving and updating A Data Manipulation Language (DML) for retrieving and updating data.data.

Commands to control access to data (security)Commands to control access to data (security)

Page 18: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Relational DatabasesRelational Databases

Relational database management system (RDBMS)Relational database management system (RDBMS) organizes data into tables or relationsorganizes data into tables or relations

TablesTables are two dimensional data structures are two dimensional data structures Tuples Tuples –– rowsrows or records – represents a specific occurrence or records – represents a specific occurrence

of an entityof an entity FieldsFields –– columns columns or attributesor attributes

Tables have primary key field(s) that can be used Tables have primary key field(s) that can be used to identify unique recordsto identify unique records

KeysKeys relate tables to each other… foreign keys relate tables to each other… foreign keys

Page 19: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Partial Display of Relational Database TablePartial Display of Relational Database Table

Page 20: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Database designDatabase design

High Level – “logical”High Level – “logical” Detailed – “physical”Detailed – “physical”

Page 21: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

High Level Design High Level Design

Create table for each entity typeCreate table for each entity type

Choose or invent primary key for each tableChoose or invent primary key for each table

Add Add foreign keysforeign keys to represent one-to-many to represent one-to-many relationshipsrelationships

Create new tables to represent many-to-many Create new tables to represent many-to-many relationshipsrelationships

Page 22: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

High Level DesignHigh Level Design

Define Define referential integrityreferential integrity constraints constraints

Evaluate schema quality and make necessary Evaluate schema quality and make necessary improvements…. improvements…. normalizationnormalization

Choose appropriate data types and value Choose appropriate data types and value restrictions (if necessary) for each fieldrestrictions (if necessary) for each field

Valid valuesValid values

Valid ranges Valid ranges

Page 23: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

RMO Entity-Relationship DiagramRMO Entity-Relationship Diagram

Page 24: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Relationship Between Data in Two TablesRelationship Between Data in Two Tables

Page 25: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Representing RelationshipsRepresenting Relationships

Relational databases use foreign keys to represent Relational databases use foreign keys to represent relationshipsrelationships

One-to-many relationshipOne-to-many relationship Add primary key field of “one” entity type as foreign key in Add primary key field of “one” entity type as foreign key in

table that represents “many” entity typetable that represents “many” entity type

Many-to-many relationshipMany-to-many relationship Use the primary key field(s) of both entity types Use the primary key field(s) of both entity types Use (or create) an associative entity table to represent Use (or create) an associative entity table to represent

relationshiprelationship

Page 26: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Entity Tables with Primary Keys Entity Tables with Primary Keys (Figure 12-7)(Figure 12-7)

Page 27: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Represent One-to-Many Relationships by Represent One-to-Many Relationships by Adding Foreign Keys (in italics) Adding Foreign Keys (in italics) (Figure 12-8)(Figure 12-8)

Page 28: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Enforcing Referential IntegrityEnforcing Referential Integrity

Consistent relational database stateConsistent relational database state

Every foreign key value also exists as a primary Every foreign key value also exists as a primary key valuekey value

DBMS enforces referential integrity automatically DBMS enforces referential integrity automatically after schema designer identifies primary and after schema designer identifies primary and foreign keysforeign keys

Page 29: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

DBMS Referential Integrity EnforcementDBMS Referential Integrity Enforcement

When rows containing foreign keys are createdWhen rows containing foreign keys are created DBMS ensures that value also exists as a primary key in a DBMS ensures that value also exists as a primary key in a

related tablerelated table

When row is deletedWhen row is deleted DBMS ensures no foreign keys in related tables have same DBMS ensures no foreign keys in related tables have same

value as primary key of deleted rowvalue as primary key of deleted row

When primary key value is changedWhen primary key value is changed DBMS ensures no foreign key values in related tables contain DBMS ensures no foreign key values in related tables contain

the same valuethe same value

Page 30: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

RI in DDLRI in DDL

RI is defined RI is defined when defining when defining

the foreign keys the foreign keys associated with associated with

a tablea table

Page 31: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Evaluating Schema QualityEvaluating Schema Quality

High-quality data model hasHigh-quality data model has

Uniqueness of table rows and primary keysUniqueness of table rows and primary keys

Ease of implementing future data model changes (flexibility Ease of implementing future data model changes (flexibility and maintainability)and maintainability)

Lack of redundant data (database Lack of redundant data (database normalizationnormalization))

Database design is not objective or quantitatively Database design is not objective or quantitatively measured; it is experience and judgment basedmeasured; it is experience and judgment based

Page 32: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

NormalizationNormalization

A good data model:A good data model: Is simple – all attributes in an entity describe only that Is simple – all attributes in an entity describe only that

entity. entity. Is non-redundant. All attributes other than foreign keys Is non-redundant. All attributes other than foreign keys

describe one entitydescribe one entity Is flexible and adaptive. Is flexible and adaptive.

Normalization is a data analysis technique that Normalization is a data analysis technique that organizes data attributes such that they are grouped organizes data attributes such that they are grouped to form non-redundant, stable, flexible, and adaptive to form non-redundant, stable, flexible, and adaptive entities.entities.

Page 33: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Database NormalizationDatabase Normalization

Normal forms minimize data redundancyNormal forms minimize data redundancy First normal form (1NF)First normal form (1NF) – no repeating fields or groups of – no repeating fields or groups of

fieldsfields Functional dependencyFunctional dependency – one-to-one relationship between – one-to-one relationship between

the values of two fieldsthe values of two fields 2NF2NF – in 1NF and if each non-key element is functionally – in 1NF and if each non-key element is functionally

dependent on entire primary keydependent on entire primary key 3NF3NF – in 2NF and if no non-key element is functionally – in 2NF and if no non-key element is functionally

dependent on any other non-key elementdependent on any other non-key element

Page 34: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

First Normal FormFirst Normal Form

AND…AND…

The first normal form states that each field is granular and there are no repeating groups

Page 35: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Second/Third Normal FormSecond/Third Normal FormThe second normal form states that each field in a multiple field primary key table must be directly related to the entire primary key. Third normal form is the same as second normal form except that it only refers to tables that have a single field as their primary key. 

Page 36: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

ExerciseExercise

Define what would need to be done place data in Define what would need to be done place data in first normal form (look carefully at the data)first normal form (look carefully at the data)

Place this data in 3Place this data in 3rdrd normal form normal form

Page 37: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Detailed DesignDetailed Design

Design physical representationDesign physical representation Analyze transactionsAnalyze transactions Choose file organizationsChoose file organizations Choose indexesChoose indexes Estimate disk space requirements Estimate disk space requirements

Design user views Design user views Design security mechanismsDesign security mechanisms Consider the introduction of controlled Consider the introduction of controlled

redundancy redundancy Monitor and tune the operational systemMonitor and tune the operational system

Page 38: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Analyze TransactionsAnalyze Transactions

Assume that a transaction = use caseAssume that a transaction = use case Use this information to identify the parts of the Use this information to identify the parts of the

database that may cause performance problems. database that may cause performance problems. To select appropriate file organizations and indexes, To select appropriate file organizations and indexes,

also need to know high-level functionality of the also need to know high-level functionality of the transactions, such as:transactions, such as:

attributes that are updated in an update transaction attributes that are updated in an update transaction criteria used to restrict rows that are retrieved in a query.criteria used to restrict rows that are retrieved in a query.

Page 39: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Analyze TransactionsAnalyze Transactions

Often not possible to analyze all expected Often not possible to analyze all expected transactions, so investigate most transactions, so investigate most ‘‘importantimportant’’ ones ones –– use Paretto Principleuse Paretto Principle

To help identify which transactions to investigate, To help identify which transactions to investigate, can use:can use:

transaction/relation cross-reference matrixtransaction/relation cross-reference matrix, showing relations , showing relations that each transaction accesses, and/or that each transaction accesses, and/or

Access frequency analysisAccess frequency analysis. .

Page 40: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Cross-referencing transactions and relationsCross-referencing transactions and relations

Which relations require the most attention?

Page 41: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

(2) Determine frequency information(2) Determine frequency information

We need to identify the key transactions that We need to identify the key transactions that access those relationsaccess those relations

Key information includes:Key information includes: Data volumes anticipated in each relationData volumes anticipated in each relation Average and maximum number of times per period that a Average and maximum number of times per period that a

transaction executestransaction executes Peak access times for each transactionPeak access times for each transaction

Why is peak access time important to know?

Page 42: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

(2) Determine frequency information(2) Determine frequency information

Peak times are key to understanding if Peak times are key to understanding if transactions conflict; that is, have similar peak transactions conflict; that is, have similar peak times. If so, potential for performance issues is times. If so, potential for performance issues is greater.greater.

Page 43: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Transaction usage map for some sample Transaction usage map for some sample transactionstransactions

Page 44: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Choose File OrganizationsChoose File Organizations

PurposePurpose: : To determine an efficient file To determine an efficient file organization for each table.organization for each table.

Determines how records physically ordered on diskDetermines how records physically ordered on disk File organizations type: unordered, ordered, hash.File organizations type: unordered, ordered, hash. Rule of Thumb: Use DBMS default organizationRule of Thumb: Use DBMS default organization

Page 45: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Choose IndexesChoose Indexes

Purpose: To determine whether adding indexes will Purpose: To determine whether adding indexes will improve the performance of the system.improve the performance of the system.

Need to consider both primary and secondary Need to consider both primary and secondary indexesindexes

Primary Index Primary Index –– how data will be physically ordered on disk how data will be physically ordered on disk Secondary Index Secondary Index –– additional indexes created to speed access additional indexes created to speed access

to datato data

Page 46: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Why do indexes improve performance?Why do indexes improve performance?

Without an index, need to scan tablesWithout an index, need to scan tables Index = table with very few attributes. Index = table with very few attributes. Use the index to find the record(s) that meet query Use the index to find the record(s) that meet query

criteria. criteria.

Page 47: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Estimate Disk Space RequirementsEstimate Disk Space Requirements

Purpose: To estimate the amount of disk space that Purpose: To estimate the amount of disk space that will be required by the database.will be required by the database.

We need to do this step to ensure that we have sufficient We need to do this step to ensure that we have sufficient hardware and disk capacity both now and in the future to hardware and disk capacity both now and in the future to manage the database.manage the database.

To calculate storage, need to consider:To calculate storage, need to consider: Amount of data required by each table (width of each row * count of rows)Amount of data required by each table (width of each row * count of rows) Indexes to be maintainedIndexes to be maintained Log files to be maintainedLog files to be maintained Growth over a defined time period (1 Growth over a defined time period (1 –– 2 years) 2 years)

Page 48: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Design User ViewsDesign User Views

PurposePurpose: To design the user views that were : To design the user views that were identified during the requirements stage of the identified during the requirements stage of the relational database application lifecycle.relational database application lifecycle.

On multi-user systems, views are often used to On multi-user systems, views are often used to manage security, reduce complexity for usersmanage security, reduce complexity for users

Page 49: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Other Detailed Design TasksOther Detailed Design Tasks

Design security mechanismsDesign security mechanisms Consider the introduction of controlled redundancy Consider the introduction of controlled redundancy Monitor and tune the operational systemMonitor and tune the operational system

Page 50: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Object-Oriented DatabasesObject-Oriented Databases

Direct extension of OO design and programming Direct extension of OO design and programming paradigmparadigm

ODBMSODBMS stores data as objects stores data as objects Direct support for method storage, inheritance, Direct support for method storage, inheritance,

nested objects, object linking, and programmer-nested objects, object linking, and programmer-defined data typesdefined data types

Object Definition Language (ODL)Object Definition Language (ODL) Standard language for describing structure and content of an Standard language for describing structure and content of an

object database object database

Page 51: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Designing Object DatabasesDesigning Object Databases

Determine which classes require persistent Determine which classes require persistent storagestorage

Define Define persistent classespersistent classes

Represent relationships among persistent classesRepresent relationships among persistent classes

Choose appropriate data types and value Choose appropriate data types and value restrictions (if necessary) for each fieldrestrictions (if necessary) for each field

Page 52: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Representing ClassesRepresenting Classes

Transient classesTransient classes Objects exist only during lifetime of program or processObjects exist only during lifetime of program or process Examples: view layer window, pop-up menuExamples: view layer window, pop-up menu

Persistent classesPersistent classes Objects not destroyed when program or process ceases Objects not destroyed when program or process ceases

execution. State must be remembered.execution. State must be remembered. Exist independently of program or processExist independently of program or process Examples: customer information, employee informationExamples: customer information, employee information

Page 53: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Representing RelationshipsRepresenting Relationships

Object identifiersObject identifiers Used to identify objects uniquelyUsed to identify objects uniquely Physical storage address or referencePhysical storage address or reference Relate objects of one class to anotherRelate objects of one class to another

ODBMS uses attributes containing object ODBMS uses attributes containing object identifiers to find objects that are related to other identifiers to find objects that are related to other objectsobjects

Similar to…..?Similar to…..?

Keyword Keyword relationshiprelationship can be used to declare can be used to declare relationships between classesrelationships between classes

Page 54: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Representing Relationships (Representing Relationships (continuedcontinued))

Advantages includeAdvantages include ODBMS assumes responsibility for determining connection ODBMS assumes responsibility for determining connection

among objectsamong objects ODBMS assumes responsibility for maintaining referential ODBMS assumes responsibility for maintaining referential

integrityintegrity

Type of relationshipsType of relationships 1:1, 1:M, M:M (one-to-one, one-to-many, many-to-many)1:1, 1:M, M:M (one-to-one, one-to-many, many-to-many) Association class used with M:MAssociation class used with M:M

Page 55: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

RMO Domain RMO Domain Model Class Model Class DiagramDiagram (Figure 12-15)(Figure 12-15)

Page 56: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

One-to-One Relationship Represented with One-to-One Relationship Represented with Attributes Containing Object IdentifiersAttributes Containing Object Identifiers

Page 57: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

One-to-Many Relationship Between One-to-Many Relationship Between Customer and Order ClassesCustomer and Order Classes

Page 58: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

One-to-Many Relationship Represented with Attributes One-to-Many Relationship Represented with Attributes Containing Object IdentifiersContaining Object Identifiers

Page 59: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Generalization Hierarchy within Generalization Hierarchy within the RMO Class Diagram the RMO Class Diagram (Figure 12-21)(Figure 12-21)

Page 60: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Object DBMS Realities (from Wikipedia)Object DBMS Realities (from Wikipedia)

Object databases based on persistent Object databases based on persistent programming acquired a niche in application areas programming acquired a niche in application areas such as: such as:

engineering and engineering and spatial databases, , telecommunications, and , and scientific areas such as scientific areas such as high energy physics and and molecular biology. .

They have made little impact on mainstream They have made little impact on mainstream commercial data processing, commercial data processing,

Page 61: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Object DBMS Realities (from Wikipedia)Object DBMS Realities (from Wikipedia)

ODBMS suggest that pointer-based techniques are ODBMS suggest that pointer-based techniques are optimized for very specific "search routes" or optimized for very specific "search routes" or viewpoints. However, for general-purpose queries viewpoints. However, for general-purpose queries on the same information, pointer-based techniques on the same information, pointer-based techniques will tend to be slower and more difficult to will tend to be slower and more difficult to formulate than relational. formulate than relational.

Other things that work against ODBMS: Other things that work against ODBMS: lack of interoperability with a great number of tools/features lack of interoperability with a great number of tools/features

that are taken for granted in the SQL world including but not that are taken for granted in the SQL world including but not limited to industry standard connectivity, reporting tools, limited to industry standard connectivity, reporting tools, OLAP tools and backup and recovery standards. OLAP tools and backup and recovery standards.

Lack a formal mathematical foundation, unlike the relational Lack a formal mathematical foundation, unlike the relational model, model,

Page 62: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Hybrid Object-Relational Database DesignHybrid Object-Relational Database Design

RDBMS (RDBMS (hybrid DBMShybrid DBMS) used to store object ) used to store object attributes and relationshipsattributes and relationships

Design complete relational schema and Design complete relational schema and simultaneously design equivalent set of classessimultaneously design equivalent set of classes

Mismatches between relational data and OO Mismatches between relational data and OO Class methods cannot be directly stored or automatically Class methods cannot be directly stored or automatically

executedexecuted Relationships are restricted compared to ODBMSRelationships are restricted compared to ODBMS ODBMS can represent wider range of data typesODBMS can represent wider range of data types

Page 63: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Classes and Attributes Classes and Attributes

Designers store classes and object attributes in Designers store classes and object attributes in RDBMS by table definitionRDBMS by table definition

Relational schema can be designed based on class Relational schema can be designed based on class diagramdiagram

Table is created for each classTable is created for each class Fields of each table same as attributes of classFields of each table same as attributes of class Row holds attribute values of single objectRow holds attribute values of single object Key field is chosen for each tableKey field is chosen for each table

Page 64: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

RelationshipsRelationships

Relationships are represented with foreign keys Relationships are represented with foreign keys Foreign key values serve same purpose as object Foreign key values serve same purpose as object

identifiers in ODBMSidentifiers in ODBMS 1:M relationship 1:M relationship –– add primary key field of class on add primary key field of class on

“one” side of the relationship to table representing “one” side of the relationship to table representing class on “many” side class on “many” side

M:M relationship M:M relationship –– create new table that contains create new table that contains primary key fields of related class tables and primary key fields of related class tables and attributes of the relationship itselfattributes of the relationship itself

Page 65: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Data Access ClassesData Access Classes

OO design based on a three-layer architectureOO design based on a three-layer architecture

Data access classes are implementation bridge Data access classes are implementation bridge between data stored in program objects and data between data stored in program objects and data in relational databasein relational database

Methods add, update, find, and delete fields and Methods add, update, find, and delete fields and rows in table or tables that represent the classrows in table or tables that represent the class

Methods encapsulate logic needed to copy data Methods encapsulate logic needed to copy data values from problem domain class to database and values from problem domain class to database and vice versavice versa

Page 66: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Interaction Interaction Among a Among a Domain Class, Domain Class, a Data Access a Data Access Class, and the Class, and the DBMSDBMS

(Figure 12-25)(Figure 12-25)

Page 67: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Data TypesData Types

Storage format and allowable content of program Storage format and allowable content of program variable, object state variable, or database field or variable, object state variable, or database field or attributeattribute

Primitive data types Primitive data types –– directly implemented directly implemented Memory address (pointer), Boolean, integer, and so onMemory address (pointer), Boolean, integer, and so on

Complex data types Complex data types –– user-defined user-defined Dates, times, audio streams, video images, URLsDates, times, audio streams, video images, URLs

Page 68: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Relational DBMS Data TypesRelational DBMS Data Types

Designer must choose appropriate data type for Designer must choose appropriate data type for each field in relational database schemaeach field in relational database schema

Choice for many fields is straightforwardChoice for many fields is straightforward Names and addresses use a set of fixed- or variable-length Names and addresses use a set of fixed- or variable-length

character arrayscharacter arrays Inventory quantities can use integersInventory quantities can use integers Item prices can use real numbersItem prices can use real numbers

Complex data types (DATE, LONG, LONGRAW)Complex data types (DATE, LONG, LONGRAW)

Page 69: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Subset of Oracle RDBMS Data TypesSubset of Oracle RDBMS Data Types

Page 70: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Object DBMS Data TypesObject DBMS Data Types

Use set of primitive and complex data types Use set of primitive and complex data types comparable to RDBMS data typescomparable to RDBMS data types

Schema designer can create new data types and Schema designer can create new data types and associated constraintsassociated constraints

Classes are complex user-defined data types that Classes are complex user-defined data types that combine traditional concept of data with combine traditional concept of data with processes (methods) to manipulate dataprocesses (methods) to manipulate data

Page 71: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Distributed DatabasesDistributed Databases

Rare for all organizational data to be stored in a Rare for all organizational data to be stored in a single database in one locationsingle database in one location

Different information systems in an organization Different information systems in an organization are developed at different timesare developed at different times

Parts of an organization’s data may be owned and Parts of an organization’s data may be owned and managed by different unitsmanaged by different units

System performance is improved when data is System performance is improved when data is near primary applicationsnear primary applications

Page 72: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Single Database Server Architecture Single Database Server Architecture (Figure 12-27)(Figure 12-27)

Page 73: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Replicated Database Server ArchitectureReplicated Database Server Architecture(Figure 12-28)(Figure 12-28)

Page 74: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Partitioned Database Server ArchitecturePartitioned Database Server Architecture

Page 75: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Advantages of DDBMSsAdvantages of DDBMSs

Reflects organizational structureReflects organizational structure Improved shareability and local autonomyImproved shareability and local autonomy Improved availabilityImproved availability Improved reliabilityImproved reliability Improved performanceImproved performance EconomicsEconomics Modular growthModular growth

Page 76: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Disadvantages of DDBMSsDisadvantages of DDBMSs

ComplexityComplexity CostCost SecuritySecurity Integrity control more difficultIntegrity control more difficult Lack of standardsLack of standards Lack of experienceLack of experience Database design more complexDatabase design more complex

Page 77: INFORMATION SYSTEMS @ X INFO425: Systems Design Chapter 13 Database Design.

INFO425: Systems DesignINFO425: Systems Design

INFORMATION SYSTEMS @ XINFORMATION SYSTEMS @ X

Functions of a DDBMSFunctions of a DDBMS

Expect DDBMS to have at least the functionality of a Expect DDBMS to have at least the functionality of a DBMS.DBMS.

Also to have following functionality:Also to have following functionality: Extended communication services.Extended communication services. Extended Data Dictionary.Extended Data Dictionary. Distributed query processing.Distributed query processing. Extended concurrency control.Extended concurrency control. Extended recovery services.Extended recovery services.