Database Design Introduction How does a relational database implement entities, attributes, and relationships from a logical data model?. Database Design Information System System Info
Trang 1Database Design
Introduction
What are the similarities and differences between conventional files and modern, relational databases?
What are of fields, records, files, and databases? What are some examples of each?
What is a modern data architecture that includes files, operational databases, data warehouses, personal databases, and work group databases?
What are the similarities and differences between the roles of
systems analyst, data administrator, and database administrators as they relate to databases?
What is the architecture of a database management system?
Trang 2Database Design
Introduction
How does a relational database implement entities, attributes, and relationships from a logical data model?
How do you normalize a logical data model to remove impurities that can make a database unstable, inflexible, and non-scaleable?
How do you transform a logical data model into a physical,
relational database schema?
How do you generate SQL code to create the database structures in
a schema?
Trang 3• The key word is interrelated
• The records in each file must allow for relationships (think of them
as ‘pointers’) to the records in other files
In the file environment, data storage is built around the
applications that will use the files
In the database environment, applications will be built around the integrated database
Trang 4Database Design
Information System
System
Information System
Database (consolidated &
integrated data from files) File
File
Information System
Information System
Trang 5 Historically, another advantage of conventional files has been processing speed
Trang 6Database Design
Conventional Files Versus the
Database
As legacy file-based systems and applications become candidates for reengineering, the trend is overwhelmingly in favor of
replacing file-based systems and applications with database
systems and applications
Trang 7 Databases allow the use of the data in ways not originally
specified by the end-users - data independence
The database scope can even be extended without impacting
existing programs that use it
• New fields and record types can be added to the database without affecting current programs.
Trang 8required
programmers must learn how to use the DBMS
and database specialists must adhere to rigorous design principles
increased vulnerability inherent in the use of shared data.
Trang 9Database Design
Conventional Files Versus the
Database
To fully exploit the advantages of database technology, a database must be carefully designed
The end product is called a database schema, a technical blueprint
of the database
Database design translates the data models that were developed for the system users during the definition phase, into data structures supported by the chosen database technology
Subsequent to database design, system builders will construct
those data structures using the language and tools of the chosen database technology
Trang 10FOCUS ON SYSTEM PROCESSES
FOCUS ON SYSTEM INTERFACES
Existing Applications and Technology
Existing Interfaces and Technology
Existing Networks and Technology
FOCUS ON SYSTEM GEOGRAPHY
Implementation Phase (translate technical design into code)
Design Phase (translate business requirements into a technical design)
Definition Phase (establish and prioritize business system requirements)
Study Phase (establish system improvement objectives)
Survey Phase (establish scope and project plan)
ORDER order-no order-date products-ordered
Customers order zero,
one, or more products
Products may be ordered
by zero, one, or more
CREATE TABLE CUSTOMER
(customer_no CHAR(10) NOT NULL
customer_name CHAR(32) NOT NULL
customer _rating CHAR(1) NOT NULL
balance_due DECIMAL(5,2)
CREATE INDEX cust_no_idx on CUSTOMER
CREATE INDEX cust_rt_idx on CUSTOMER
Trang 11Database Design
Database Concepts for the Systems
Analyst
Fields are common to both files and databases
A field is the implementation of a data attribute
• Fields are the smallest unit of meaningful data to be stored in a file
or database.
There are four types of fields that can be stored: primary keys,
secondary keys, foreign keys, and descriptive fields.
one record in a file
• A single file in a database may only have one primary key, but it
may have several secondary keys.
Trang 12 There are four types of fields that can be stored: primary keys,
secondary keys, foreign keys, and descriptive fields (continued)
database
• Foreign keys are how the database ‘links’ the records of one type
to those of another type.
Trang 13Database Design
Database Concepts for the Systems
Analyst
fixed-length or variable-fixed-length records
meaning that each record instance has the same fields, same number of fields, and same logical size
same file to have different lengths
length records
Trang 14 When a computer program ‘reads’ a record from a database, it
actually retrieves a group or block of records at a time
This approach minimizes the number of actual disk accesses
A blocking factor is the number of logical records included in
a single read or write operation (from the computer’s
perspective) A block is sometimes called a physical record.
Today, the blocking factor is usually determined and optimized
by the chosen database technology, but a qualified database expert may be allowed to fine tune that blocking factor for performance
Trang 15Database Design
Database Concepts for the Systems
Analyst
usually called a table.
permanent
system indefinitely
the individual records are retained indefinitely
Trang 16Database Design
Database Concepts for the Systems
Analyst
Some of the types of files and tables include: (continued)
business events
• The data describing these events normally has a limited useful lifetime
• In information systems, transaction records are frequently retained
on-line for some period of time
• Subsequent to their useful lifetime, they are archived off-line.
data for easy retrieval and review without the overhead of generating the document
Trang 17re-Database Design
Database Concepts for the Systems
Analyst
Some of the types of files and tables include: (continued)
records that have been deleted from on-line storage
• Records are rarely deleted; they are merely moved from on-line storage to off-line storage
• Archival requirements are dictated by government regulation and the need for subsequent audit or analysis.
shared by applications to maintain consistency and improve performance
Trang 18Database Design
Database Concepts for the Systems
Analyst
Some of the types of files and tables include: (continued)
especially master and transaction files
• They are used in conjunction with archive files to recover ``lost’’ data
• Audit trails are typically built into better database technologies.
Trang 19 Out of necessity, database technology was created so an
organization could maintain and use its data as an integrated whole instead of as separate data files
Trang 20 A business’ data architecture is comprised of the files and
databases that store all of the organization’s data, the file and database technology used to store the data, and the organization structure set up to manage the data resource
day-to-day operations and business transaction processing for major information systems
Trang 21production databases and conventional files
– Fourth-generation programming languages, query tools, and
decision support tools are then used to generate reports and analyses off these data warehouses.
Trang 22• These databases may contain unique data, or they may import data
from conventional files, operational databases, and/or data warehouses
Trang 23• A data administrator is responsible for the data planning,
definition, architecture, and management.
– One or more database administrators are responsible for the
database technology, database design and construction, security, backup and recovery, and performance tuning.
Trang 24Database Design
A legacy file-based information system (built in-house)
File
(built in-house)
Information System (built in-house)
Operational Database File
File
Information System (built in-house)
A legacy file-based information system (purchased)
File File File
Information System (purchased)
Operational Database
Data Warehouse
End-User Tools
End-User Applications
Personal DB
Work-Group Database
Users and Programmers
Users
End-User Work Group
Trang 25including the database engine, database management utilities, database CASE tools for analysis and design, and database application development tools.
management system
software available from computer vendors that is used to create, access, control, and manage the database The core of the DBMS is
often called its database engine The engine responds to specific
commands to create database structures, and then to create, read, update, and delete records in the database.
Trang 26record types, and relationships that exist between record types.
These structures are defined to the database management system using its data definition language
physically establish those record types, fields, and structural relationships Additionally, the DDL defines views of the database Views restrict the portion of a database that may be used or
accessed by different users and programs DDLs record the definitions in a permanent data repository.
Trang 27Database Design
Database Management System (DBMS)
Data Definition Language DDL
Data Manipulation Language DML
Proprietary Data Manipulation Language and/or Report Writers
Host-based Transaction Processing Monitor (optional)
Internal
TP Monitor (opt)
Trang 28helps database specialists track metadata – the data about the
data –such as record and field definitions, synonyms, data relationships, validation rules, help messages, and so forth
manipulation language to access and use the database in applications
update, and delete records in the database, and to navigate between different records and types of records The DBMS and DML hide the details concerning how records are organized and allocated to the disk.
Trang 29 Some DBMSs include a transaction processing monitor (or
TP monitor) that manages on-line accesses to the database, and
ensures that transactions that impact multiple tables are fully processed as a single unit
Trang 30can be classified according to the way they structure records
hierarchies or networks implemented with indexes and linked lists.
‘related’ to one another via foreign keys.
relations
Trang 32Quantity Ordered
Trang 33Database Design
Database Concepts for the Systems
Analyst
Relational Database Management Systems:
Both the DDL and DML of most relational databases is called
SQL (which stands for Structured Query Language)
• SQL supports not only queries, but complete database creation and maintenance
• A fundamental characteristic of relational SQL is that commands return ‘a set’ of records, not necessarily just a single record (as in non-relational database and file technology).
Trang 34 Relational Database Management Systems:
High-end relational databases also extend the SQL language to support triggers and stored procedures
automatically invoked by a updates to another table
be called from an application program.
Both triggers and stored procedures are reusable because they are stored with the tables themselves
• This eliminates the need for application programmers to create the
equivalent logic within each application that use the tables.
Trang 35Database Design
Data Analysis for Database Design
A good data model is simple
As a general rule, the data attributes that describe an entity should describe only that entity
A good data model is essentially non-redundant
This means that each data attribute, other than foreign keys, describes at most one entity
A good data model should be flexible and adaptable to future
Trang 36implementation as a simple, non-redundant, flexible, and adaptable database The specific technique is called
normalization.
that they are grouped together to form stable, flexible, and adaptive entities.
Trang 37 An entity is in first normal form (1NF) if there are no
attributes that can have more than one value for a single instance of the entity
An entity is in second normal form (2NF) if it is already in
1NF, and if the values of all non-primary key attributes are dependent on the full primary key – not just part of it
An entity is in third normal form (3NF) if it is already in
2NF, and if the values of its non-primary key attributes are not dependent on any other non-primary key attributes
Trang 38Database Design
Data Analysis for Database Design
First Normal Form:
The first step in data analysis is to place each entity into 1NF
Trang 39Database Design
MEMBER ORDER -Key Data - Order-Number (PK)
-Non-Key Data - Order-Creation-Date
Order-Automatic-Fill-Date Member Number (FK1)
Member-Name Member-Address
Shipping-Address Shipping Instructions Club-Name (FK2) Promotion-Number (FK2)
Title-Cover Catalog-Description Copyright-Date Entertainment-Category Credit-Value
Director Video-Category Video-Sub-Category Closed-Captioned Language Running-Time
GAME TITLE -Key Data - Product-Number (PK1) Universal-Product-Code (PK1) -Non-Key Data - Manufacturer
Game-Category Game-Sub-Category Game-Platform Game-Media-Type Number-of-Players Parent-Advisory-Code
is a
is a
MEMBER -Key Data - Member-Number (PK1)
-Non-Key Data - Member-Name
Member-Status Member-Street-Address Member-Daytime-Phone-Number Date-of-Last-Order Member-Balance-Due Member-Bonus-Balance-Available Member-Credit-Card-Information
-Non-Key Data - Club-Description
enrolls in
sponsors
generates
features
Trang 40MEMBER ORDERED PRODUCT (1NF) -Key Data - Member-Number (PK1) (FK) Product-Number (PK1) (FK) -Non-Key Data - Ordered-Product-Description Ordered-Product-Title Quantity-Ordered Purchased-Unit-Price Extended-Price CORRECTION
sold as
MEMBER ORDER (1NF) -Key Data - Order-Number (PK)
-Non-Key Data - Order-Creation-Date
Order-Automatic-Fill-Date Member Number (FK1) Member-Name Member-Address Shipping-Address Shipping Instructions Club-Name (FK2) Order-Sub-Total-Cost Order-Sales-Tax Ship-Via-Method Shipping-Charge Order-Status Prepaid-Amount
sells
Trang 41-Non-Key Data - Club-Description
Club-Charter-Date
CORRECTION
AGREEMENT (1NF) -Key Data - Club-Name (PK1) (FK) Agreement-Number (PK1) -Non-Key Data - Agreement-Active-Date Agreement-Expiration-Date Obligation-Period
Required-Number-of-Credits Bonus-Credits-After-Obligation
establishes
Trang 42-Non-Key Data - Member-Name
Member-Status Member-Street-Address Member-Daytime-Phone-Number Date-of-Last-Order
Member-Balance-Due Member-Bonus-Balance-Available Member-Credit-Card-Information
CLUB MEMBERSHIP (1NF) -Key Data - Member-Number (PK1) (FK) Club-Name (PK1) (FK) Agreement-Number (PK1) (FK) -Non-Key Data - Taste Code
Media Preference Date-Enrolled Expiration-Date Number-of-Credits-Required Number of Credits-Earned
CLUB (1NF) -Key Data - Club-Name (PK)
-Non-Key Data - Club-Description
Club-Charter-Date
AGREEMENT (1NF) -Key Data - Club-Name (PK1) (FK) Agreement-Number (PK1) -Non-Key Data - Agreement-Active-Date Agreement-Expiration-Date Obligation-Period Required-Number-of-Credits Bonus-Credits-After-Obligation
enrolls in
binds
establishes
sponsors CORRECTION