database management systems - Çankaya...
TRANSCRIPT
Spring 2015
Database Management Systems
Course Information
Instructors:
Roya Choupani
Office: L209
Tel. (312) 2331346
Email: [email protected]
Reza Hassanpour
Office: L214
Tel. (312) 2331338
Email: [email protected]
Teaching Assistants: Emre Akkuş
Tel: (312) 2331348
Email: [email protected]
Course Web Page: http://ceng356.cankaya.edu.tr
Course Objectives
To provide the basis for data handling and management, and
the related algorithms and techniques.
To make students able to apply data management and storage
optimization techniques to a given problem.
To write queries to manipulate data
Data Management
In File Organization we learned to optimize file access.
The methods discussed were:
Sorting and searching files
Indexing
Hashing
In this course we learn how to manage data
Data Management Example
Assume a file is created to store the employee data of a
company
Data is:
Employee Name Department Location Department
Phone
Project Project Start
Date
Duration
Ali Engineering Cankaya 12345 Construction 2010 3
Hasan Engineering Cankaya 12345 Construction 2010 3
Mehmet Engineering Cankaya 12345 Construction 2010 3
Zeynep Engineering Cankaya 12345 Construction 2010 3
Tolga Engineering Cankaya 12345 Construction 2010 3
Problems in the Example File
Some data items are repeated. (if the department has 10,000
employees, location and department phone will be
repeated 10,000 times)
If a data item changes (phone number for example), all
records should be updated
File access (input/output) becomes very slow
Optimizing Data Management Employee Name Department Project
Ali Engineering Construction
Hasan Engineering Construction
Mehmet Engineering Construction
Zeynep Engineering Construction
Tolga Engineering Construction
Department Location Department
Phone
Engineering Cankaya 12345
Project Project
Start Date
Duration
Construction 2010 3
Database Management System
A database management system (DBMS) is a program that
enables
storing,
modifying,
extracting
information from a database.
It also provides tools to analyze data stored in a location
Example DBMS: ORACLE, MS-SQL, MySQL,…
Course Outline
• Introduction – Data, Database, Database Management Systems
– Data Models
– Database Languages
• Relational Databases – Relations and Tables
– Attributes
– Integrity Constraints
• Relational Algebra / Relational Calculus
• SQL – Queries
– Data Modifications
• Database Design – Entity Relationship Model (ER Model)
– Normalization
• Transactions
Text Book
Database Systems, Concepts, Languages and Architectures,
By: Paolo Atzeni, Stefano Ceri, Stefano Paraboschi, and
Riccardo Torlone, Published by McGraw-Hill,
ISBN:0077095006
Fundamentals of Database Systems, Fourth Edition, Elmasri
and Navathe, Addison Wesley Press, ISBN:0-312-20448-4
Evaluation
• Homework 15%
– Lab assignments, you may use any DBMS
• Programming Project 25-30%
– Includes designing a database, creating tables, inserting data,
writing queries.
– Report
– Presentation + Demo
• Midterm 30%
• Final 30%
(5 bonus points you may get from term project)
Database Management Systems
Introduction
2/17/2015 Database Management Systems, 12
Topics
Definitions
Data, Database, Database Management Systems
Importance of DBMS and Applications
Data Modeling
Query and Query Languages
Concurrency Control
Transaction
2/17/2015 Database Management Systems, 13
Data and Information
Data is the result of a measurement, event or fact.
Numbers, characters, symbols, images etc., which can be
processed by a computer.
Example: Ali
Information is the data that has been processed to be
meaningful to the person who receives it.
Information is the knowledge derived from study, experience
(by the senses), or instruction.
Example: Ali is the manager
2/17/2015 Database Management Systems, 14
Databases
A collection of data which
Models the real world entities (Student, employee, etc. )
Models the relationships (e.g., Hasan is taking CENG 356)
Hence a database includes both data and information
2/17/2015 Database Management Systems, 15
Example
A University Database is a collection of:
Student (entity)
Courses (entity)
Instructors (entity)
Relations such as
Which students are taking a given course
Who is offering a given course
Etc.
2/17/2015 Database Management Systems, 16
Files and Databases
Databases are using file systems but they extend them as
follows:
Databases are more efficient (By using indexing, hashing and
other optimization tools)
Concurrent access to data is safer in databases
Data security is better
2/17/2015 Database Management Systems, 17
Database Management Systems
(DBMS)
A Database Management System (DBMS) is a software
designed to store and manage databases.
DBMS
Provides access to data
Protects data from inconsistency due to multiple concurrent
users
Provides security
and more…
2/17/2015 Database Management Systems, 18
Example Databases
Airline Reservation System Database
List of flights
List of seats sold for each flight
List of passenger names
Concurrent access control (several sale agencies may sell a seat
at the same time)
Fast search for a flight, passenger, connection, etc.
Restrict access to database (Security)
2/17/2015 Database Management Systems, 19
Importance of DBMS
DBMS provides the possibility of storing and extracting
information and data
e.g. The Employee-Department relationship
DBMS can handle data sets of very large sizes
e.g. Millions of data items in a typical data set
DBMS can handle the diversity of data sets
e.g. Numbers, String, Images, Video, Audio, etc.
Many subjects in computer science include a database (AI,
Operating Systems, Multimedia, etc )
2/17/2015 Database Management Systems, 20
Sharing Data The data of the various parts often overlap
e.g. Student affairs and Library in University database
A database is a resource, shared by various parts
e.g. Student address and phone number shared by Student affairs and Library
Sharing reduces redundancy and the probability of inconsistency
e.g. Phone number changes are reflected to all departments
Since sharing is never complete, DBMS provides support for privacy of data
Sharing also requires that multiple accesses to data are suitably organized
2/17/2015 Database Management Systems, 21
Data Models
A data model is the method for describing data.
The relational model of data is the most widely used model
today.
A relation is basically a table with rows and columns.
2/17/2015 Database Management Systems, 22
Relational Data Model Example
2/17/2015 Database Management Systems, 23
Example: University Database
2/17/2015 24
Query
In general, a query is a form of questioning, but we will use the
term for updating data/information also.
e.g. Find all students taking CENG 356 in spring 2010 from the
University database (Retrieve Query)
e.g. Increase the salaries of all employees by 10% in Employee
database (Update Query)
2/17/2015 Database Management Systems, 25
Query Languages
Query languages are used for writing queries.
Query languages have three types:
Text based languages: e.g. SQL
Embedded in programming languages like C or C++: e.g.
embedded SQL
Graphical Interfaced Query Languages: e.g. Microsoft Access
2/17/2015 Database Management Systems, 26
Query Language Example (1)
SQL
SELECT Course, Room, Floor
FROM Rooms, Courses
WHERE Code = Room
AND Floor=”Ground"
2/17/2015 Database Management Systems, 27
Query Language Example (2)
2/17/2015 Database Management Systems, 28
Concurrency Control
Concurrent execution of user programs.
Concurrency is essential for good DBMS performance.
Problems: Inconsistency
e.g., check is cleared while account balance is being computed
2/17/2015 Database Management Systems, 29
Transactions
Each instruction given to a database is either executed
completely, or cancelled. This is called a transaction.
e.g. Instruction given as : “Increase the salary of all employees
by 10%”.
If the system crashes before completing the execution, we will
not know whose salary has been updated. (Inconsistency)
If the instruction is executed as a transaction, inconsistency will
not happen.
2/17/2015 Database Management Systems, 30
Summary DBMS is used to maintain, and query large datasets
Benefits of DBMS are:
Sharing data
Less redundancy
Data consistency
Concurrency control
Data security
Efficiency of handling data
Disadvantage:
Cost
?
2/17/2015 Database Management Systems 31
Questions?
2/17/2015 Database Management Systems, 32