Chapter 01 Introduction
Chapter 01 Introduction
– Data
Data vs. Information
• "data" and "information" are often used to mean the same thing
• However, they have different meanings in database terminology:
• What are data?
– Unorganized or unprocessed raw facts
• What is Information?
– Data with special meaning
– The result of sorting, combining, comparing, analyzing or performing
calculations on data (raw facts)
Data versus Information
5
Data vs. Information
The DBMS transforms stored data
into meaningful information
Data: Each student's exam score is
one piece of data
Information: The class average for
the exam is individual pieces or
data transformed into information
Data vs. Information Examples
• Data
– (1) Students test scores
– (2) Weekly sales for each salesperson
– (3) Inventory count for each product at each warehouse
• Information
– (1) Class average
– (2) Bonus as a percent of sales for the week
– (3) The total company inventory for each product
Data versus Information
• Is your student number data or information?
– When is it data?
– When is it information?
11
NULL Value
• NULL means missing, unknown, or unassigned
• It is not zero (numeric) or space (alphanumeric) – it is NULL
• Consider a Customer table:
– Missing – Perhaps a customer, such as Sally, does not divulge her age to
the customer service representative
– Unknown – An employee’s termination date is usually some event in
the unforeseen future
– Unassigned (doesn't apply) – If the customer is a business, then Sex
does not apply and thus is unassigned
• Data that can be NULL, is optional data 12
System-Development Life Cycle (SDLC)
1. Database Planning
2. Requirements Analysis
3. Database Design
4. Database Build
5. Testing and Evaluation
6. Database Deployment (Implementation)
7. Database Maintenance
13
Step 1: Database Planning
• Starts when a customer (user) submits a request for the
development of a database
• Four major activities are performed:
– Review and approve the database project request
– Prioritize the database project request
– Allocate resources such as money, people, and tools
– Assign development team to develop the database project
14
Step 2: Requirements Analysis
• Also known as the systems analysis phase
• Includes investigation and analysis of the request
• Results in a set of requirements that the database must support
• Includes:
– What data is to be stored
– What are the relationships between the data
– What processes are involved
– Business rules
15
Step 3: Database Design
• Database Design has two phases:
– Phase 1: Data Modeling
Development of a graphical diagram that represents the proposed database,
usually an Entity-Relationship Diagram (ERD)
Independent of any hardware and software considerations
An ERD stays the same regardless of what type of DBMS the system is
eventually built with
– Phase 2: Physical Model
A data model representing the database to be implemented
Shows tables, relationships, columns, and data types
Levels of Database Modeling
17
Conceptual Data Modeling
• A high-level graphical representation of the proposed database
– Entity-Relationship Diagram (ERD)
– Identifies entities and basic relationships
18
Conceptual Data Modeling
• ER diagram for conceptual data model answers the questions:
– What entities (person, place, or thing) are being represented?
– Which entities have relationships?
19
Logical Data Modeling
• A logical data model is:
– A continuation of the data modeling process where more details are
added to the ER diagram
– Independent of any particular DBMS such as DB2, Oracle, MS SQL
Server, and MySQL
– Shows entities, attributes, and detailed relationships
20
Logical Data Modeling
• ER diagram for logical data model answers the questions:
– What entities (person, place, or thing) are being represented?
– What attributes (data) are stored about each entity?
– What are the relationships between the entities?
– Basically, what data do we want to capture and what are the business
rules surrounding that data
21
Example ERD
Logical Data Model
22
Normalization
• A technique used during database design to identify redundancy
within the database
23
Relational (Physical) Data Modeling
• A data model expressed in terms of a relational database
structure (DB2, Oracle, MS SQL Server, and MySQL)
• The logical data model is transformed into a relational (physical)
data model based on the DBMS being used for implementation
– Database terms are used instead of data modeling terms
For example, entities become tables
24
Step 4: Database Build
• Create the database
– SQL Data Definition Language (DDL) statements
For the selected DBMS according to the requirements specified in the
physical data model
DBMS specific – DB2 is used in this course
– Implement integrity constraints from business rules
25
Step 5: Testing & Evaluation
• Test all constraints
• Verify that all requirements have been met
26
Step 6: Database Deployment
• Allocate storage requirements
• Place the database into production
27
Step 7: Database Maintenance
• Database Maintenance
– Maintain the database on an on-going basis according to user
requirements
28
Introduction to SQL Statements
• SQL pronounced "S-Q-L" stands for Structured Query Language
• The industry-standard language of relational database
management systems (RDBMS) for manipulating and querying
data in a relational database
29
SQL Statements
• SQL commands are categorized into four categories:
– DDL (Data Definition Language)
– DML (Data Manipulation Language)
– DCL (Data Control Language)
– TCL (Transaction Control Language)
30
DDL (Data Definition Language)
• SQL commands used to create and modify the structure of
database objects:
– CREATE – create the database or its objects (table, index, function,
views, store procedure and triggers)
– DROP – delete objects from the database
– ALTER – alter the structure of the database
– TRUNCATE – remove all rows (records) from a table
– COMMENT – add comments to the data dictionary
– RENAME – Rename an object existing in the database
31
DML (Data Manipulation Language)
• SQL commands that deal with the manipulation of data in a
database:
– SELECT – retrieve data from the a database
– INSERT – insert data into a table
– UPDATE – update existing data within a table
– DELETE – delete rows (records) from a database table
32
DCL (Data Control Language)
• SQL commands that deal with the rights, permissions, and other
controls of the database system:
– GRANT – gives user’s access privileges to database
– REVOKE – withdraw user’s access privileges given by using the GRANT
command
33
TCL (Transaction Control Language)
• SQL commands that deal with the transactions within the
database:
– COMMIT– commits a transaction
– ROLLBACK – rollbacks or reverses a transaction when errors occur
– SAVEPOINT – sets a SAVEPOINT within a transaction
– SET TRANSACTION – specifies characteristics for a transaction
34
Creating a Schema
• A schema must be created before the creation of tables and
other SQL objects
• A schema is an object that serves as a container for database
objects, such as tables, views, indexes, stored procedures, and
other object types
• A schema is created by entering the CREATE SCHEMA
command, followed by the name of the schema, followed by a
semicolon
• CREATE SCHEMA myschema;
35