Introduction

advertisement
INTRODUCTION
OBJECTIVES
o
At the end of this lesson, you will be able to:
 Describe the life-cycle development phases
 Discuss the theoretical and physical aspects of a relational
database
 Describe the MySQL implementation of the RDBMS
SYSTEM DEVELOPMENT LIFE CYCLE
Strategy
and
Analysis
Design
Build
and
Document
Transition
Production
DATA STORAGE ON DIFFERENT MEDIA
SALGRADE
GRADE
LOSAL
HISAL
--------- --------- --------DEPTNO DNAME
LOC
1
700
1200
--------- -------------- ---------2
1201
1400
10 ACCOUNTING
NEW YORK
3
1401
2000
20 RESEARCH
DALLAS
4
2001
3000
30 SALES
CHICAGO
5
3001
9999
40 OPERATIONS
BOSTON
DEPT
Electronic
spreadsheet
Filing cabinet
Database
RELATIONAL DATABASE CONCEPT
o
o
o
Dr. E. F. Codd proposed the relational model for database
systems in 1970.
It is the basis for the relational database management system
(RDBMS).
The relational model consists of the following:
 Collection of objects or relations
 Set of operators to act on the relations
 Data integrity for accuracy and consistency
DATA MODELS
Model of system
in client’s mind
Entity model of
client’s model
Table model
of entity model
Server
Tables on disk
ENTITY RELATIONSHIP MODEL
Create an entity relationship diagram from business specifications or
narratives
EMPLOYEE
#*
number
*
name
o
job title
assigned to
composed of
DEPARTMENT
#*
number
*
name
o
location
Scenario
– “. . . Assign one or more employees to a department . . .”
– “. . . Some departments do not yet have assigned employees .
. .”
ENTITY RELATIONSHIP MODELING
CONVENTIONS
Entity
Soft box
Singular, unique name
Uppercase
Synonym in parentheses
EMPLOYEE
#*
number
*
name
o
job title
Attribute
Singular name
Lowercase
Mandatory marked with “*”
Optional marked with “o”
assigned to
composed of
Unique Identifier (UID)
Primary marked with “#”
Secondary marked with “(#)”
DEPARTMENT
#*
number
*
name
o
location
RELATIONAL DATABASE PROPERTIES
o
A relational database
 Can be accessed and modified by executing structured
query language (SQL) statements
 Contains a collection of tables with no physical pointers
 Uses a set of operators
RELATIONAL DATABASE DEFINITION
o
A relational database is a collection of relations or
two-dimensional tables.
Database
Table Name: EMP
EMPNO
ENAME
JOB
DEPTNO
7839
7698
7782
KING
BLAKE
CLARK
PRESIDENT 10
MANAGER
30
MANAGER
10
7566
JONES
MANAGER
20
Table Name: DEPT
DEPTNO
DNAME
LOC
10
20
30
ACCOUNTING
RESEARCH
SALES
NEW YORK
DALLAS
CHICAGO
40
OPERATIONS
BOSTON
RELATIONAL DATABASE TERMINOLOGY
2
4
3
EMPNO ENAME
JOB
MGR
HIREDATE
SAL
COMM
DEPTNO
6
------------- ------------ --------------------- -------- ---------------- ----------- --------------
1
7839 KING
PRESIDENT
7698 BLAKE
MANAGER
7782 CLARK
-----------
17-NOV-81
5000
10
7839
01-MAY-81
2850
30
MANAGER
7839
09-JUN-81
2450
10
7566 JONES
MANAGER
7839
02-APR-81
2975
20
7654 MARTIN
SALESMAN
7698
28-SEP-81
1250
1400
30
7499 ALLEN
SALESMAN
7698
20-FEB-81
1600
300
30
7844 TURNER SALESMAN
7698
08-SEP-81
1500
0
30
7900 JAMES
CLERK
7698
03-DEC-81
950
7521 WARD
SALESMAN
7698
22-FEB-81
1250
7902 FORD
ANALYST
7566
03-DEC-81
3000
20
7369
SMITH
CLERK
7902
17-DEC-80
800
20
7788
SCOTT
ANALYST
7566
09-DEC-82
3000
20
7876
ADAMS
CLERK
7788
12-JAN-83
1100
20
7934
MILLER
CLERK
7782
23-JAN-82
1300
10
5
30
500
30
RELATING MULTIPLE TABLES
• Each row of data in a table is uniquely identified by a primary key (PK).
• You can logically relate data from multiple tables using foreign keys
(FK).
Table Name: EMP
EMPNO
7839
7698
7782
7566
ENAME
KING
BLAKE
CLARK
JONES
Primary key
Table Name: DEPT
JOB
PRESIDENT
MANAGER
MANAGER
MANAGER
DEPTNO
10
30
10
20
Foreign key
DEPTNO
10
20
30
40
DNAME
ACCOUNTING
RESEARCH
SALES
OPERATIONS
Primary key
LOC
NEW YORK
DALLAS
CHICAGO
BOSTON
SQL STATEMENTS
SELECT
Data retrieval
INSERT
UPDATE
DELETE
Data manipulation language (DML)
CREATE
ALTER
DROP
RENAME
TRUNCATE
Data definition language (DDL)
COMMIT
ROLLBACK
SAVEPOINT
Transaction control
GRANT
REVOKE
Data control language (DCL)
MySQL: RELATIONAL DATABASE
MANAGEMENT SYSTEM
Server
User tables
Data
dictionary
COMMUNICATING WITH A RDBMS USING SQL
SQL statement is entered
SQL> SELECT loc
2 FROM
dept;
Statement is sent to
database
Database
Data is displayed
LOC
-------------
NEW YORK
DALLAS
CHICAGO
BOSTON
TABLES USED IN THE COURSE
EMPLOYEE
EMPNO
--------7839
7698
7782
7566
ENAME
---------KING
BLAKE
CLARK
JONES
7654 MARTIN
7499 ALLEN
7844 TURNER
7900 JAMES
DEPTNO 7521
DNAMEWARD
FORD
--------- 7902
-------------SMITH
10 7369
ACCOUNTING
SCOTT
20 7788
RESEARCH
30 7876
SALESADAMS
MILLER
40 7934
OPERATIONS
10AA
DEPARTMENT
JOB
MGR HIREDATE
SAL
COMM
DEPTNO
--------- --------- --------- --------- --------- --------PRESIDENT
17-NOV-81
5000
10
MANAGER
7839 01-MAY-81
2850
30
MANAGER
7839 09-JUN-81
1500
10
MANAGER
7839 02-APR-81
2975
20
SALESMAN
SALESMAN
SALESMAN
CLERK
SALESMAN
LOC
ANALYST
---------CLERK
NEW
YORK
7698
7698
7698
7698
7698
7566
7902
28-SEP-81
20-FEB-81
08-SEP-81
03-DEC-81
22-FEB-81
03-DEC-81
17-DEC-80
ANALYST
DALLAS
CLERK
CHICAGO
CLERK
BOSTON
7566 09-DEC-82
7788 12-JAN-83
7782 23-JAN-82
1250
1600
1500
950
1250
3000
800
GRADE
1400
300
0
500
SALARY_GRADE
30
30
30
30
30
20
20
HISAL
LOSAL
3000 --------- --------20
--------1100 1
20
700
1200
1300 2
1201
1400
3
4
5
1401
2001
3001
2000
3000
9999
SUMMARY
o
Relational databases are:
 Composed of relations
 Managed by relational operations
 Governed by data integrity constraints
o
o
MySQL is based on the relational database management
system.
MySQL allows you to store and manage information by
using the SQL language.
Download