You are on page 1of 23

Introduction

„ About CSIS0278
„ What is a database? Why do we need Database Systems?
„ How is application data represented in a DBMS?
„ How is data in a DMBS retrieved and manipulated?
„ What are the main components of a DBMS?
„ Who needs/operates database systems in real life?

Intro. to Dababase Management Systems 1.1 Lecture notes by Nikos Mamoulis


About the course

„ CSIS0278B: Introduction to Database Management Systems


„ Instructor
¾ Dr. N. Mamoulis
„ Tutors
¾ LI, Jing
¾ WANG, Hao
„ Information:
¾ http://i.cs.hku.hk/~c0278b
¾ Contains:
ƒ Course description
ƒ Lecture notes
ƒ Tutorials
ƒ Assignments
ƒ Grading scheme
ƒ Contact info and office hours

Intro. to Dababase Management Systems 1.2 Lecture notes by Nikos Mamoulis


About the course

„ Course textbook:
¾ A. Silberschatz, H. F. Korth, and S. Sudarshan, Database System
Concepts, Fifth Edition, McGraw-Hill, 2005
¾ can be found at the University Bookstore
¾ 6th edition to be published soon
„ Teaching Schedule
Lectures:
¾ Monday, 2:00pm - 3:55pm, LE8 (Library Extension),
¾ Thursday, 3:00pm - 3:55pm, CB-A (Chow Yei Ching Bldg)
Tutorials:
¾ On some Thursdays there will be tutorials instead of lectures
¾ Additional tutorials will be arranged as necessary

Intro. to Dababase Management Systems 1.3 Lecture notes by Nikos Mamoulis


About the course

„ Introduction
¾ This is an introductory course.
„ to database management
¾ This course is about data management. You will learn the
fundamental concepts of database design
„ Systems
¾ You will get basic knowledge about the functionality of a database
system.

Intro. to Dababase Management Systems 1.4 Lecture notes by Nikos Mamoulis


Topics Covered

1 Introduction
2 ER Model and Conceptual Design
3 Relational Model
4 Relational Algebra
5 SQL
6 Relational Database Design
7 Database Application Development
8 Storage
9 Indexing
10 Transaction Management

Intro. to Dababase Management Systems 1.5 Lecture notes by Nikos Mamoulis


Student Assessment

„ The students are assessed by take-home assigments, and in-


class quizzes/examinations
„ Assignments (30%)
¾ There will be three assignments related to database design and
implementation.
„ Mid-term Examination (20%)
¾ The midterm examination will be held on Monday 8 March.
„ Final Examination (50%)

Intro. to Dababase Management Systems 1.6 Lecture notes by Nikos Mamoulis


Tutorials

„ A tutorial may include the following


¾ Solutions to exercises
¾ Explanation of the material in assignments. Instructions on how to
solve the assignments
¾ Solutions to exam papers
„ You are encouraged to attend all tutorials in order to digest the
course material
„ Use your tutor to learn the most you can out of the course.
Interact with him during class and find him at his office whenever
you have problems/questions.

Intro. to Dababase Management Systems 1.7 Lecture notes by Nikos Mamoulis


What is a Database?

„ Database = large collection of interrelated data


„ A database contains information about a particular enterprise
„ Database Applications:
¾ Banking: customers, transactions, loans, branches
¾ Airlines: reservations, schedules
¾ Universities: registration, grades
¾ Sales: customers, products, purchases
¾ Manufacturing: production, inventory, orders, supply chain
¾ Human resources: employee records, salaries, tax deductions
„ An example familiar to you?
¾ http://www.imdb.com/

Intro. to Dababase Management Systems 1.8 Lecture notes by Nikos Mamoulis


An important problem

„ Problem: How can we organize and store these data, such that:
¾ they are securely stored
ƒ they can be saved after a system crash!
ƒ I don’t want everyone to access every part of the data!
¾ they can be updated efficiently
ƒ if I want to insert or delete some information, I can do it fast!
¾ they can be accessed efficiently
ƒ I can retrieve fast only the information I really want from the database!
¾ they can be accessed conveniently
ƒ I don’t need to write a special program every time I want to access
something in the database!
¾ they can be accessed/updated concurrently by many users
ƒ I don’t have to wait someone else to finish accessing the data before me!
¾ they are not redundant
ƒ I want the data to occupy as small space as possible in the computer!
¾ they are consistent
ƒ I don’t want anyone to insert inconsistent data in the database (e.g., age = 0)

Intro. to Dababase Management Systems 1.9 Lecture notes by Nikos Mamoulis


Database Management System (DBMS)

„ Solution: Database Management System:


¾ A set of programs that store and access the data
¾ A good DBMS aims at handling all problems related to management
of large databases
¾ Examples of big DBMS vendors: Oracle, IBM (DB2), Microsoft (SQL
Server)
„ DBMS provides an environment that is both convenient and
efficient to use
„ convenient:
¾ You don’t have to be a computer expert to use a DMBS; you don’t
even need to be a programmer
¾ You only need to learn the data accessing tools, e.g., a query
language, like SQL, or even only a user interface on top of a DBMS
„ efficient:
¾ your requests to access/update the database will be served within
acceptable time

Intro. to Dababase Management Systems 1.10 Lecture notes by Nikos Mamoulis


Why not use a file system, instead of a
Database Management System?
„ In the early days, database applications were built on top of file
systems
„ Advantages of a DBMS over a file system:
¾ Data independence
ƒ Application programs that access a DBMS do not care about the
details of data representation and storage
ƒ They exchange information with the DBMS via an API
ƒ Reduced application development time
¾ Efficient data access
¾ Data integrity and security
ƒ Inconsistent data are not allowed in the DBMS (e.g. account balance
> 0)
¾ Data administration
ƒ Multiple users, one administrator
¾ Concurrent access by multiple users
ƒ Concurrent accessed needed for performance
ƒ Uncontrolled concurrent accesses can lead to inconsistencies
– E.g. two people reading a balance and updating it at the same
time

Intro. to Dababase Management Systems 1.11 Lecture notes by Nikos Mamoulis


Instances and Schemas

„ Similar to values and variables in programming languages


„ Schema – the logical structure of the database
¾ e.g., 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
¾ Logical (or conceptual) schema: database design at the logical level
¾ Physical schema: database design at the physical level
„ Instance – the actual content of the database at a particular point in time
¾ Analogous to the value of a variable
„ 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.

Intro. to Dababase Management Systems 1.12 Lecture notes by Nikos Mamoulis


Data Models

„ A collection of tools for describing


¾ data
¾ data relationships
¾ data semantics
¾ data constraints
„ The relational model of data is the most widely used model
today.
¾ Main concept: relation, basically a table with rows and columns.
¾ Every relation has a schema, which describes the columns, or
fields.
¾ Relation schema is similar to record in Pascal or struct in C
programming languages
¾ Relation instance is a set of records that comply to a relation
schema
ƒ similar to an array of records in programming languages

Intro. to Dababase Management Systems 1.13 Lecture notes by Nikos Mamoulis


A Sample Relational Database Instance
schema
of relation
customer

instance
of relation
customer

Q:
relationship
between
these
tables?

Intro. to Dababase Management Systems 1.14 Lecture notes by Nikos Mamoulis


View of Data
An architecture for a database system

Users or
applications
that access
the database

Conceptual
design of the DB

Physical storage
of the DB
+ indexes

• Data independence: Application programs are insulated from changes in the way the
data are structured and stored

Intro. to Dababase Management Systems 1.15 Lecture notes by Nikos Mamoulis


Users of the DBMS
„ Simple users (e.g., your grandmother)
¾ They access the DB through application programs with user
interfaces designed for the simple user. They do not need to know
programming or anything about databases.
¾ Example: your grandmother accesses the balance of her bank
account, through the web interface of the bank
„ Application programmers
¾ They develop programs on top of existing DBMSs that access and
manipulate information stored in the DB
¾ Example: the programmer of the bank web interface
„ Database administrator (DBA)
¾ Responsible for the logical and physical design of the database.
Performs tuning by selecting appropriate indexes for the database,
based on the expected requests from users or application
programmers.
¾ Example: the DBA of the bank DB
„ Also: Developer of the DBMS
¾ Responsible for the design of the system itself. Similar to the
developer of an operating system.

Intro. to Dababase Management Systems 1.16 Lecture notes by Nikos Mamoulis


Database Administrator:
a very special user
„ Full control over the database. Responsible for database
design and maintenance.
„ Coordinates all the activities of the database system; the
database administrator has a good understanding of the
enterprise’s information resources and needs.
„ Database administrator's duties include:
¾ Schema definition
¾ Storage structure and access method definition
¾ Schema and physical organization modification
¾ Granting user authority to access the database
¾ Specifying integrity constraints
¾ Acting as liaison with users
¾ Monitoring performance and responding to changes in
requirements

Intro. to Dababase Management Systems 1.17 Lecture notes by Nikos Mamoulis


Transaction Management

„ A transaction is a collection of simple operations that performs a single


logical function in a database application
¾ Ex: Transaction T1: transfer $1000 from account A to account B in a bank
database
„ Transactions are atomic: they must happen in their entirety or not at all.
„ Transaction-management component ensures that the database
remains in a consistent (correct) state despite system failures (e.g.,
power failures and operating system crashes) and transaction failures.
„ Every change after a transaction should be made persistent; if the
system crashes it should not be lost (durability).
¾ Changes should be reflected to disk
„ A concurrency-control manager controls the interaction among the
concurrent transactions, to ensure the consistency of the database.
¾ Ex: Transaction T2: print A+B
¾ Q: What happens if T2 runs in the middle of T1?

Intro. to Dababase Management Systems 1.18 Lecture notes by Nikos Mamoulis


Storage Management

„ Storage manager is a program module of the DMBS that


provides the interface between the low-level data stored in the
database and the application programs and queries submitted to
the system.
¾ query: a well-structured inquiry to the database for retrieving
information
„ The storage manager is responsible to the following tasks:
¾ interaction with the file manager
¾ efficient storing, retrieving and updating of data
ƒ databases are usually large, so they should be stored to disks
ƒ it is important to store the data in a way such that the transferred
information to/from disks during an operation is minimized
ƒ it is important to use wisely the memory in order to cache the
most frequently accessed data there

Intro. to Dababase Management Systems 1.19 Lecture notes by Nikos Mamoulis


Query Processing

„ The query processor is an intelligent program module of the


DMBS that converts the high-level user requests to efficient low-
level commands to the database.
¾ From end-user, administrator, or programmer
¾ Query processor is similar to API, parser, and/or compiler
„ The query processor is responsible for
¾ Translating high-level information retrieval requests (queries) to
requests to the storage manager in order to access/update data
efficiently
¾ Interpreting data definition requests and recording the definitions in
the data dictionary

Intro. to Dababase Management Systems 1.20 Lecture notes by Nikos Mamoulis


Overall System Structure

DML: Data
Manipulation
Language
A layered
DDL: Data
architecture Definition
Language

SQL is both DML


and DDL

Intro. to Dababase Management Systems 1.21 Lecture notes by Nikos Mamoulis


What you will learn in CSIS0278
„ Play the role of the database administrator
¾ Logically design the database
¾ Physically create the database and insert the initial data
¾ Do simple physical database design (e.g., index selection)
„ Be an application programmer for a DBMS
¾ Use DBMS APIs to create applications (designed for the
simple user), which manage the data in a database.
„ Internals of DBMS functionality
¾ Learn how the DBMS stores data on the disk
¾ Learn how indexes that improve access efficiency are
designed
¾ Learn how the system manages concurrent transactions
¾ More in the advanced database systems course

Intro. to Dababase Management Systems 1.22 Lecture notes by Nikos Mamoulis


Summary
„ DBMS used to maintain and query large collections of
data
„ Many benefits over the use of a simple file manager (i.e.,
just write some programs over an OS)
„ Levels of abstraction (physical, logical, application) give
data independence. A DBMS typically has a layered
architecture.
„ DB administrator is an important well-paid(!) job.
„ DB application programming is a must qualification for
many jobs

Intro. to Dababase Management Systems 1.23 Lecture notes by Nikos Mamoulis

You might also like