2. Database
Objectives of this session
•What is a Database?
• Where and when we need to use
Databases
• Types of users in a Database
• Database Design
08/15/17 2
4. • Database is a collection of data organized to
service many applications at the same time by
storing and managing data so that they appear to
be in one location.
08/15/17 4
What is Database
5. Application of Databases
• Banking: For customer information, accounts, and
loans, and banking transactions.
• Airlines: For reservations and schedule information.
• Universities: For student information, course
registrations, and grades.
• Credit card transactions: For purchases on credit
cards and generation of monthly statements.
• Telecommunications: For keeping records of calls
made, generating monthly bills, maintaining balances on
prepaid calling cards, and storing information about the
communication networks.
08/15/17 5
6. • Finance: For storing information about holdings,
sales, and purchases of financial instrument such as
stocks and bonds.
• Sales: For customers, product, and purchase
information.
• Manufacturing: For management of supply chain
and for tracking production of items in factories,
inventories of items in warehouses/stores, and orders
for items
• Human resources: For information about employees,
salaries, payroll taxes and benefits, and for generation
of paychecks.
08/15/17 6
7. Data Hierarchy
The data hierarchy comprises: bits, bytes, fields,
records, files, and database.
Bit: Smallest unit of data represented by 1 or 0.
Byte: A group of 8 bits
Field: Unit of data consisting of one or more
characters. For example id, name, address.
Record: A collection of related fields
File: A collection of related records
Database: A collection of related files
08/15/17 7
8. Disadvantages of traditional file system
• Data redundancy: Same information may be
duplicated in several places.
• Inconsistency: The various copies of same data may
no longer agree
• Difficulty in accessing data: Conventional file-
processing environments do not allow needed data
to be retrieved in a convenient and efficient manner.
• Data isolation: Data are scattered in various files, and
files may be in different formats.
08/15/17 8
9. • Integrity problems
Data values stored in the database must satisfy
certain types of consistency constraints. It is
difficult to satisfy these constraints in traditional
file system.
• Atomicity problems
It must happen in its entirety or not at all. It is
difficult to ensure atomicity in a conventional file-
processing system.
08/15/17 9
10. • Concurrent-access anomalies
Concurrent accessed needed for performance
• Uncontrolled concurrent accesses can lead to
inconsistencies
•Example: Two people reading a balance and
updating it at the same time
• Security problems
• Hard to provide user access to some, but not all, data
•
08/15/17 10
11. File Organization
File organization deals with the physical organization of
the records of a file for the convenience of storage and
retrieval of data records.
Sequential file organization: A method of storing data
records in which the records must be retrieved in the
same physical sequence in which they are stored.
Advantages: 1. Simple 2. Easy to organize 3. Requires
inexpensive storage media
Disadvantage: 1. Inefficient for application 2. Slow
Random file organization: Allows users to access
records in any sequence without regard to actual
physical order on the storage media.
08/15/17 11
12. Advantages: 1. Can be retrieved quickly
2. Need not be sorted 3. Support interactive online
applications
Disadvantages: 1. Requires expensive hardware 2. Not
suitable for sequential processing
Indexed Sequential file organization: A method to directly
access records organized sequentially using an index of
the key fields.
Advantages: 1. Efficient for sequential processing 2. Also
suitable for random access processing
Disadvantages: 1. Requires expensive hardware 2. Requires
more storages
08/15/17 12
13. Database-Management System
• A database-management system (DBMS) is a
collection of interrelated data and a set of programs
to access those data.
Three Components
• Data-Definition Language (DDL)
• Data Manipulation Language (DML)
• Data Dictionary
08/15/17 13
14. DDL
• We specify a database schema by a set of definitions
expressed by a special language called a data-definition
language (DDL). For instance, the following statement
in the SQL language defines the account table:
Create table account
(account-number char(10),
balance integer)
Execution of the above DDL statement creates the
account table. In addition, it updates a special set of
tables called data dictionary or data directory. A data
dictionary contains metadata-that is, data about data.
08/15/17 14
15. DMLDML
08/15/17 15
Data manipulation isData manipulation is
•• The retrieval of information stored in the databaseThe retrieval of information stored in the database
•• The insertion of new information into the databaseThe insertion of new information into the database
•The deletion of information from the databaseThe deletion of information from the database
•The modification of information stored in the databaseThe modification of information stored in the database
A data-manipulation language (DML) is a language
that enables users to access or manipulate data as
organized by the appropriate data model.
•Example: SQL (Structured Query Language)
QBE (Query By Example)
16. 08/15/17 16
Example of an SQL
SELECT id, name
FROM student
WHERE id=10
Execution of the above SQL statement display the student
information with id value equal to 10.
17. Data Dictionary
Data dictionary is an automated or manual tool for storing and
organizing information about the data maintained in a
database.
08/15/17 17
18. View of Data
• Data Abstraction:
A major purpose of a database system is to
provide users with an abstract view of the data.
That is, the system hides certain details of how
the data are stored and maintained.
08/15/17 18
19. Levels of Abstraction
• Physical level: describes how a record (e.g.,
customer) is stored.
• Logical level: describes data stored in database,
and the relationships among the data.
type customer = record
customer_id : string;
customer_name : string;
customer_street : string;
customer_city : integer;
end;
08/15/17 19
20. Fig: Relationship among three levels
• View level: application programs hide details of data
types. Views can also hide information (such as an
employee’s salary) for security purposes.
08/15/17 20
An architecture for a database system
21. Database Models/ Types of Database
Organization
Principal database models are
• Hierarchical Model / Database
• Network Model / Database
• Relational Model / Database
• Entity-Relationship Model / Database
• Object-Oriented Model / Database
08/15/17 21
22. Hierarchical Data Model
• Hierarchical data model is one type of logical database model
that organizes data in a treelike structure. A record is
subdivided into segments that are connected to each other in
one-to-many parent-child relationships.
08/15/17 22
Employee
Compensation Benefits
Performance
Job
Assignments
Salary
History Insurance HealthPension
23. Network Data Model
• Network data model is logical database model that is
useful for depicting many-to-many relationships.
08/15/17 23
Course 2Course 1 Course 3
Student 1 Student 2 Student 4Student 3 Student 5
24. Relational Data Model
• Relational data model is a type of logical database model
that treats data as if they were stored in two-dimensional
tables. It can relate data stored in one table to data in
another table as long as the two tables share a common
data elements.
• A tuple is a row or record in a relational database.
08/15/17 24
IDID NameName
11 AAAA
22 BBBB
IDID MarksMarks GradeGrade
11 7070 B+B+
22 8080 A+A+
STUDENT
RESULT
25. Object Oriented Data Model
• An object Oriented database is an approach to data
management that stores both data and the procedures
acting on the data as objects that can be automatically
retrieved and shared.
08/15/17 25
26. Security
The data stored in the database need protection from
unauthorized access and malicious destruction or
alteration, in addition to the protection against accidental
introduction of inconsistency that integrity constraints
provide.
08/15/17 26