14.1 Dr. Honghui Deng Assistant Professor MIS Department UNLV MIS 370 System Analysis Theory.

30
14.1 Dr. Honghui Deng Dr. Honghui Deng Assistant Professor Assistant Professor MIS Department MIS Department UNLV UNLV MIS 370 System Analysis Theory
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    220
  • download

    2

Transcript of 14.1 Dr. Honghui Deng Assistant Professor MIS Department UNLV MIS 370 System Analysis Theory.

14.1

Dr. Honghui DengDr. Honghui Deng

Assistant ProfessorAssistant Professor

MIS DepartmentMIS Department

UNLVUNLV

MIS 370 System Analysis Theory

14.2

Chapter 14Chapter 14

DATABASE DESIGNDATABASE DESIGN

MIS 370 System Analysis Theory

14.3

Learning ObjectivesLearning Objectives

• Compare and contrast conventional files and modern, relational Compare and contrast conventional files and modern, relational databases.databases.

• Define and give examples of fields, records, files, and databases.Define and give examples of fields, records, files, and databases.• Describe modern data architecture of files, operational databases, Describe modern data architecture of files, operational databases,

data warehouses, personal databases, and work group databases.data warehouses, personal databases, and work group databases.• Compare roles of systems analyst, database administrator, and Compare roles of systems analyst, database administrator, and

data administrator.data administrator.• Describe architecture of database management systemDescribe architecture of database management system• Describe how a relational database implements entities, attributes, Describe how a relational database implements entities, attributes,

and relationships from a logical data model.and relationships from a logical data model.• Transform a logical data model into a physical, relational database Transform a logical data model into a physical, relational database

schema.schema.

• Generate SQL to create the database structure in a schemaGenerate SQL to create the database structure in a schema..

14.4

Conventional Files versus the DatabaseConventional Files versus the Database

• FileFile – a collection of similar records. – a collection of similar records.– Files are unrelated to each other except in

the code of an application program.

– Data storage is built around the applications that use the files.

• DatabaseDatabase – a collection of – a collection of interrelatedinterrelated files files– Records in one file (or table) are physically

related to records in another file (or table).

– Applications are built around the integrated database

14.5

Files versus DatabaseFiles versus Database

14.6

Pros and Cons of Conventional FilesPros and Cons of Conventional Files

ProsPros• Easy to design because Easy to design because

of their single-of their single-application focusapplication focus

• Excellent performance Excellent performance due to optimized due to optimized organization for a organization for a single applicationsingle application

ConsCons• Harder to adapt to Harder to adapt to

sharing across sharing across applicationsapplications

• Harder to adapt to new Harder to adapt to new requirementsrequirements

• Need to duplicate Need to duplicate attributes in several attributes in several files.files.

14.7

Pros and Cons of DatabasesPros and Cons of Databases

ProsPros• Data independence from Data independence from

applications increases applications increases adaptability and flexibilityadaptability and flexibility

• Superior scalabilitySuperior scalability• Ability to share data Ability to share data

across applicationsacross applications• Less, and controlled Less, and controlled

redundancy (total non-redundancy (total non-redundancy is not redundancy is not achievable)achievable)

ConsCons• More complex than file More complex than file

technologytechnology• Somewhat slower Somewhat slower

performanceperformance• Investment in DBMS and Investment in DBMS and

database expertsdatabase experts• Need to adhere to design Need to adhere to design

principles to realize principles to realize benefitsbenefits

• Increased vulnerability due Increased vulnerability due to consolidating data in a to consolidating data in a centralized databasecentralized database

14.8

FieldsFields

• FieldField – the smallest unit of meaningful data to – the smallest unit of meaningful data to be stored in a databasebe stored in a database– the physical implementation of a data attribute

– Primary key – a field that uniquely identifies a record.

– Secondary key – a field that identifies a single record or a subset of related records.

– Foreign key – a field that points to records in a different file.

– Descriptive field – any nonkey field.

14.9

RecordsRecords

• RecordRecord – a collection of fields arranged – a collection of fields arranged in a predetermined format.in a predetermined format.– Fixed-length record structures

– Variable-length record structures

• Blocking factorBlocking factor – the number of logical – the number of logical records included in a single read or write records included in a single read or write operation (from the computer’s operation (from the computer’s perspective).perspective).

14.10

Files and TablesFiles and Tables

• FileFile – the set of all occurrences of a given record – the set of all occurrences of a given record structure.structure.

• TableTable – the relational database equivalent of a file. – the relational database equivalent of a file.• Types of conventional files and tablesTypes of conventional files and tables

– Master files – Records relatively permanent though values may change

– Transaction files – Records describe business events

– Document files – Historical data for review without overhead of regenerating document

– Archival files – Master and transaction records that have been deleted

– Table lookup files – Relatively static data that can be shared to maintain consistency

– Audit files – Special records of updates to other files

14.11

Data ArchitectureData Architecture

• Data architectureData architecture – a definition of how: – a definition of how:– Files and databases are to be developed and used to store data

– The file and/or database technology to be used

– The administrative structure set up to manage the data resource

• Data is stored in some combination of:Data is stored in some combination of:– Conventional files

– Operational databases – databases that support day-to-day operations and transactions for an information system. Also called transactional databases.

– Data warehouses – databases that store data extracted from operational databases.

• To support data miningTo support data mining

– Personal databases

– Work group databases

14.12

A Modern Data ArchitectureA Modern Data Architecture

14.13

AdministratorsAdministrators

• Data administratorData administrator – a database specialist – a database specialist responsible for data planning, definition, responsible for data planning, definition, architecture, and management.architecture, and management.

• Database administratorDatabase administrator – a specialist – a specialist responsible for database technology, responsible for database technology, database design, construction, security, database design, construction, security, backup and recovery, and performance backup and recovery, and performance tuning.tuning.– A database administrator will administer one

or more databases

14.14

Database ArchitectureDatabase Architecture

• Database architectureDatabase architecture – the database technology used – the database technology used to support data architectureto support data architecture– Including the database engine, database utilities, CASE tools,

and database development tools.

• Database management system (DBMS)Database management system (DBMS) – special – special software used to create, access, control, and software used to create, access, control, and manage a database. manage a database. – The core of the DBMS is its database engine.– A data definition language (DDL) is that part of the engine

used to physically define tables, fields, and structural relationships.

– A data manipulation language (DML) is that part of the engine used to create, read, update, and delete records in the database, and navigate between different records in the database.

14.15

Typical DBMS ArchitectureTypical DBMS Architecture

14.16

Relational DatabasesRelational Databases

• Relational databaseRelational database – a database that implements – a database that implements stored data in a series of two-dimensional tables that stored data in a series of two-dimensional tables that are “related” to one another via foreign keys.are “related” to one another via foreign keys.– The physical data model is called a schema.– The DDL and DML for a relational database is

called SQL (Structured Query Language).– Triggers – programs embedded within a database

that are automatically invoked by updates.– Stored procedures – programs embedded within a

database that can be called from an application program.

14.17

From Logical Data ModelFrom Logical Data Model

14.18

14.19

User Interface for a Relational PC DBMSUser Interface for a Relational PC DBMS

14.20

What is a Good Data Model?What is a Good Data Model?

• A good data model is simpleA good data model is simple– The data attributes that describe an entity should

describe only that entity

• A good data model is essentially A good data model is essentially nonredundantnonredundant– Each data attribute exists in at most one entity

(except for foreign keys)

• A good data model should be flexible and A good data model should be flexible and adaptable to future needsadaptable to future needs

These goals are achieved through database These goals are achieved through database normalization.normalization.

14.21

Database NormalizationDatabase Normalization

• An logical entity (or physical table) is in An logical entity (or physical table) is in first normalfirst normal formform if there are no attributes (fields) that can have if there are no attributes (fields) that can have more than one value for a single instance (record).more than one value for a single instance (record).

• An logical entity (or physical table) is in An logical entity (or physical table) is in second second normal formnormal form if it is already in first normal form and if if it is already in first normal form and if the values of all nonprimary key attributes are the values of all nonprimary key attributes are dependent on the full primary key. dependent on the full primary key.

• An logical entity (or physical table) is in An logical entity (or physical table) is in third normal third normal formform if it is already in second normal form and if the if it is already in second normal form and if the values of all nonprimary key attributes are not values of all nonprimary key attributes are not dependent on other nonprimary key attributes.dependent on other nonprimary key attributes.

14.22

Goals of Database DesignGoals of Database Design

• A database should provide for efficient A database should provide for efficient storage, update, and retrieval of data.storage, update, and retrieval of data.

• A database should be reliable - the stored A database should be reliable - the stored data should have high integrity and data should have high integrity and promote user trust in that data.promote user trust in that data.

• A database should be adaptable and A database should be adaptable and scalable to new and unforeseen scalable to new and unforeseen requirements and applications.requirements and applications.

14.23

Database SchemaDatabase Schema

• Database schema – a model or blueprint Database schema – a model or blueprint representing the technical implementation of representing the technical implementation of the database.the database.– Also called a physical data model

14.24

A Method for Database DesignA Method for Database Design

1.1. Review the logical data model.Review the logical data model.

2.2. Create a table for each entity.Create a table for each entity.

3.3. Create fields for each attribute.Create fields for each attribute.

4.4. Create an index for each primary and secondary key.Create an index for each primary and secondary key.

5.5. Create an index for each subsetting criterion.Create an index for each subsetting criterion.

6.6. Designate foreign keys for relationships.Designate foreign keys for relationships.

7.7. Define data types, sizes, null settings, domains, and Define data types, sizes, null settings, domains, and defaults for each attribute.defaults for each attribute.

8.8. Create or combine tables to implement supertype/ Create or combine tables to implement supertype/ subtype structures.subtype structures.

9.9. Evaluate and specify referential integrity constraints.Evaluate and specify referential integrity constraints.

14.25

Data Types for Different Database TechnologiesData Types for Different Database Technologies

Logical Data TypeLogical Data Typeto be stored in field)to be stored in field)

Physical Data Type Physical Data Type MS MS AccessAccess

Physical Data TypePhysical Data TypeMicrosoft Microsoft SQL ServerSQL Server

Physical Data TypePhysical Data TypeOracleOracle

Fixed length character data Fixed length character data (use for fields with relatively (use for fields with relatively fixed length character data)fixed length character data)

TEXTTEXT CHAR (size) CHAR (size) ororcharacter (size)character (size)

CHAR (size)CHAR (size)

Variable length character data Variable length character data (use for fields that require (use for fields that require character data but for which character data but for which size varies greatly--such as size varies greatly--such as ADDRESS)ADDRESS)

TEXTTEXT VARCHAR (max size) VARCHAR (max size) ororcharacter varying (max character varying (max size)size)

VARCHAR (max size)VARCHAR (max size)

Very long character data Very long character data (use (use for long descriptions and for long descriptions and notes--usually no more than notes--usually no more than one such field per record)one such field per record)

MEMOMEMO TEXTTEXT LONG VARCHAR LONG VARCHAR ororLONG VARCHAR2LONG VARCHAR2

Integer numberInteger number NUMBERNUMBER INT (size) INT (size) ororinteger integer ororsmallinteger smallinteger orortinuintegertinuinteger

INTEGER (size) INTEGER (size) ororNUMBER (size)NUMBER (size)

Decimal numberDecimal number NUMBERNUMBER DECIMAL (size, decimal DECIMAL (size, decimal places) places) ororNUMERIC (size, decimal NUMERIC (size, decimal places)places)

DECIMAL (size, decimal DECIMAL (size, decimal places) places) ororNUMERIC (size, decimal NUMERIC (size, decimal places) places) ororNUMBERNUMBER

14.26

Data Types for Different Database TechnologiesData Types for Different Database Technologies

Logical Data TypeLogical Data Typeto be stored in field)to be stored in field)

Physical Data Physical Data Type MS Type MS AccessAccess

Physical Data TypePhysical Data TypeMicrosoft Microsoft SQL ServerSQL Server

Physical Data TypePhysical Data TypeOracleOracle

Financial NumberFinancial Number CURRENCYCURRENCY MONEYMONEY see decimal numbersee decimal number

Date (with time)Date (with time) DATE/TIMEDATE/TIME DATETIME DATETIME ororSMALLDATETIMESMALLDATETIMEDepending on Depending on precision neededprecision needed

DATEDATE

Current time Current time (use to store (use to store the data and time from the data and time from the computer’s system the computer’s system clock)clock)

not supportednot supported TIMESTAMPTIMESTAMP not supportednot supported

Yes or No; Yes or No; oror True or True or FalseFalse

YES/NOYES/NO BITBIT use CHAR(1) and set a use CHAR(1) and set a yes or no domainyes or no domain

ImageImage OLE OBJECTOLE OBJECT IMAGEIMAGE LONGRAWLONGRAW

HyperlinkHyperlink HYPERLINKHYPERLINK VARBINARYVARBINARY RAWRAW

Can designer define new Can designer define new data types?data types?

NONO YESYES YESYES

14.27

Database IntegrityDatabase Integrity

• Key integrityKey integrity – Every table should have a primary – Every table should have a primary key.key.

• Domain integrityDomain integrity – Appropriate controls must be – Appropriate controls must be designed to ensure that no field takes on an designed to ensure that no field takes on an inappropriate valueinappropriate value

• Referential integrityReferential integrity – the assurance tat a foreign – the assurance tat a foreign key value in one table has a matching primary key key value in one table has a matching primary key value in the related table.value in the related table.– No restriction– Delete: cascade– Delete: restrict– Delete: set null

14.28

Database Schema with Referential Integrity ConstraintsDatabase Schema with Referential Integrity Constraints

14.29

Database Distribution and ReplicationDatabase Distribution and Replication

• Data distribution analysisData distribution analysis establishes which business establishes which business locations need access to which logical data entities and locations need access to which logical data entities and attributes.attributes.– Centralization

• Entire database on a single server in one physical locationEntire database on a single server in one physical location

– Horizontal distribution (also called partitioning)• Tables or row assigned to different database servers/locations.Tables or row assigned to different database servers/locations.• Efficient access and securityEfficient access and security• Cannot always be easily recombined for management analysisCannot always be easily recombined for management analysis

– Vertical distribution (also called partitioning)• Specific columns of tables assigned to specific databases and serversSpecific columns of tables assigned to specific databases and servers• Similar advantages and disadvantages of HorizontalSimilar advantages and disadvantages of Horizontal

– Replication• Data duplicated in multiple locationsData duplicated in multiple locations• DBMS coordinates updates and synchronization of dataDBMS coordinates updates and synchronization of data• Performance and accessibility advantagesPerformance and accessibility advantages• Increases complexityIncreases complexity

14.30

Database Capacity PlanningDatabase Capacity Planning

• For each table sum the For each table sum the field sizesfield sizes. This is the . This is the record sizerecord size..

• For each table, multiply the For each table, multiply the record sizerecord size times times the number of entity instances to be included the number of entity instances to be included in the table (planning for growth). This is the in the table (planning for growth). This is the table sizetable size..

• Sum the Sum the table sizestable sizes. This is the . This is the database sizedatabase size..

• Optionally, add a slack capacity buffer (e.g. Optionally, add a slack capacity buffer (e.g. 10percent) to account for unanticipated 10percent) to account for unanticipated factors. This is the factors. This is the anticipated database anticipated database capacitycapacity..