You are on page 1of 28

1

Introduction to Database
Lecture 02:
Basic Concepts
Learning Objectives
2

To know about:
Database Management System (DBMS)
Application of Database
Drawbacks of File System
View of Data
Schema
Data Models
Database Languages: DML and DDL
Database Design
Storage Management
Database Users and Administrators
Overall System Structure
Database Management System (DBMS)
3

Contains information about a particular enterprise


 Collection of interrelated data
 Set of programs to access the data
 An environment that is both convenient and efficient to use
Applications of Database
4

• Banking: all transactions


• Airlines: reservations, schedules
• Universities: registration, grades
• Sales: customers, products, purchases
• Manufacturing: production, inventory, orders,
supply chain
• Human resources: employee records, salaries,
tax deductions
Databases touch all aspects of our lives
Drawbacks of Using File Systems for Data Storage
5
• Data Redundancy and • Data Isolation
Inconsistency -> Multiple files and formats
->Multiple file formats • Integrity Problems
->duplication of information ->Integrity constraints (e.g.
in different files account balance > 0)
• Difficulty in Accessing become “buried” in
Data program code rather than
->Need to write a new being stated explicitly
program to carry out each ->Hard to add new
new task constraints or change
existing ones
Drawbacks of Using File Systems for Data Storage
6

• Atomicity of • Concurrent access • Security


updates by multiple users problems
->Failures may leave ->Concurrent accessed
needed for ->Hard to provide
database in an user access to
inconsistent state performance
with partial ->Uncontrolled some, but not
updates carried concurrent accesses all, data
out can lead to
inconsistencies
Example: Transfer
of funds from one Example: Two people
account to another reading a balance and
updating it at the
should either
same time
complete or not
happen at all

Database systems offer solutions to all of the problems that have


been mentioned
View of Data
7

Database system is a collection of interrelated data


and a set of programs to access and modify these
data
Major purpose of a database system is to provide
users with an abstract view of the data
 The system hides certain details of how data are
stored and maintained
View of Data
8

An architecture for a database system


Levels of Abstraction
9

Since many database-system users  Logical level:


are not computer trained,  Next higher level
developers hide the complexity from  describes what data are
users through several levels of stored in database, and the
abstraction, to simplify users relationships among the data
interaction with the system.

 Physical level:  View level:


 Lowest level  application programs hide
 describes how a record (e.g., details of data types
customer) is stored  Views can also hide
 Complex low level data information (such as an
structures employee’s salary) for
security purposes
Schemas and Instance
10

 Schema – the logical structure of the database


 Example: The database consists of information about a set of customers
and accounts and the relationship between them)
 Analogous to type information of a variable in a program
 Physical schema: database design at the physical level
 Logical schema: database design at the logical level

 Instance – the actual content of the database at a


particular point in time
 Analogous to the value of a variable
Physical and Logical Data Independence
11

 Physical Data Independence – the ability to modify


the physical schema without changing the logical schema
 Applications depend on the logical schema
 In general, the interfaces between the various levels and components
should be well defined so that changes in some parts do not seriously
influence others

 Logical Data Independence - the ability to modify


the logical schema without causing application programs
to be rewritten.
 Required when the logical structure has been altered
Data Models
12

A collection of tools for describing


 Data
 Data relationships
 Data semantics
 Data constraints
Data Models: Relational Model
13

Relational model : The relational model uses


a collection of tables to represent both data and
the relationships among those data.
tabular data in the relational model Sample relational database
Data Models: E-R Data Model
14
The E-R data model is based on a  Represented diagrammatically
perception of a real world that by an entity-relationship
consists of a collection of basic diagram:
objects, called entities and of
relationships among these objects.

Used for Database Design

Models an enterprise as a collection


of entities and relationships
 Entity: a “thing” or “object” in the
enterprise that is distinguishable from
other objects. Described by a set of
attributes
 Relationship: an association among
several entities
Data Models: Other Data Models
15

Object-based data models (Object-oriented


and Object-relational)
Semi-structured data model (XML)
Other older models:
 Network model
 Hierarchical model
Database Language: DML
16

Stands for Data Manipulation Language

Language for accessing and manipulating the data


organized by the appropriate data model
 DML also known as query language

Type of access are:


 Retrieval of information stored in the database
 Inserting of new information into the database
 Deletion of information from the database
 Modification of information stored in the database.
Database Language: DML
17

Two classes of languages


 Procedural – user specifies what data is required and how to
get those data
 Declarative (nonprocedural) – user specifies what data is
required without specifying how to get those data

SQL is the most widely used query language

DML OPERATIONS: INSERT, UPDATE, DELETE,


MERGE
Database Language: DDL
18

Stands for Data Definition Language (DDL)

Specification notation for defining the database


schema
Example: create table account (
account-number char(10),
balance integer)

DDL compiler generates a set of tables stored in a


data dictionary
Database Language: DDL
19

Data dictionary contains metadata (i.e. data


about data)
 Database schema
 Data storage and definition language
->Specifies the storage structure and access methods used
 Integrity constraints
->Domain constraints
->Referential integrity (references constraint in SQL)
->Assertions
 Authorization

DDL OPERATIONS: CREATE, ALTER, DROP,


RENAME, TRUNCATE
SQL
20

Widely used non-procedural language


SQL is used to communicate with a database

Example: Find the name of the customer with customer-id 192-83-7465

select customer.customer_name
from customer
where customer.customer_id = ‘192-83-7465’
Database Design
21

The process of designing the general structure of the database:

Logical Design – Deciding on the database schema. Database


design requires that we find a “good” collection of relation
schemas.
 Business decision – What attributes should we record in the database?
 Computer Science decision – What relation schemas should we have and how
should the attributes be distributed among the various relation schemas?

Physical Design – Deciding on the physical layout of the


database
Storage Manager
22

Storage manager is a program module that provides the


interface between the low-level data stored in the database and
the application programs and queries submitted to the system.

The storage manager is responsible to the following tasks:


 Interaction with the file manager
 Efficient storing, retrieving and updating of data

Components of Storage Manager


 Authorization and integrity manager
 Transaction manager
 File manager
 Buffer manager
Storage Manager
23

Authorization and Integrity Manager: Checks the authority of users to


access data.

Transaction manager: Ensure that the database in a consistent state


despite system failures, and that concurrent transaction execution proceed
without conflicting.

File manager : Manage allocation of space on disk storage and the data
structures used to represent information stored on disk.

Buffer manager : Responsible for fetching data from disk storage into main
memory and decide what data to cache in main memory. The data buffer
manager is a critical part of the database system, since it enables the database
handle data sizes that are much larger than the size of main memory.
Storage Manager
24

The storage manager implements several data


structure as part of the physical system
implementation

 Data files: Store the database itself.

 Data dictionary : stores metadata about the structure of


the database, in particular the schema of the database.

 Indices: Provide first access to the data items. Like index


of the textbook.
Database Users
25
Users are differentiated by the  Specialized users
way they expect to interact with  One type of sophisticated user
the system  Write specialized database
Application programmers applications that do not fit into
 Computer professionals who write the traditional data processing
application programs framework (expert system,
 Can use RAD tools for constructing knowledge base, graphics data,
forms and reports with minimal audio data)
programming efforts.  Naive users
Sophisticated users  Invoke one of the permanent
 Interact with the system without application programs that have
writing programs been written previously
 Form requests in a database query  Read reports
language
 Examples, people accessing
 Submit query to the query processor
database over the web, bank
 Analyst
tellers,
Database Administrator
26
 Coordinates all the activities of the  Schema and physical
database system; the database organization modification
administrator has a good  Granting user authority to
understanding of the enterprise’s
access the database
information resources and needs.
 Database administrator's duties
 Specifying integrity
constraints
include:
 Schema definition : The DBA
 Acting as liaison with users
create the original database
 Monitoring performance and
schema by executing a ser of responding to changes in
data definition statements in requirements
the DDL
 Storage structure and access
method definition
Overall System Structure
27
28

THANK YOU

You might also like