I Need an A+
Introduction to Database Systems
EIND 142
Spring 2019
Database Management System (DBMS)
Collection of interrelated data
Set of programs to access the data
DBMS contains information about a particular enterprise
DBMS provides an environment that is both convenient and efficient to use.
Database Applications:
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
Basic Definitions
Need for information management
A database (DB) is a large, integrated collection of data
A DB models a real-world enterprise
Entities (e.g., students, courses)
Relationships (e.g., Laura is taking EIND464)
A database management system (DBMS) is a software package designed to store and manage databases
Databases are a very important aspect of Systems Engineering
Purpose of Database System
In the early days, database applications were built on top of file systems
Drawbacks of using file systems to store data:
Data redundancy and inconsistency
Multiple file formats, duplication of information in different files
Difficulty in accessing data
Need to write a new program to carry out each new task
Data isolation — multiple files and formats
Integrity problems
Integrity constraints (e.g. account balance > 0) become part of program code
Hard to add new constraints or change existing ones
Purpose of Database Systems (Cont.)
Drawbacks of using file systems (cont.)
Atomicity of updates
Failures may leave database in an inconsistent state with partial updates carried out
E.g. transfer of funds from one account to another should either complete or not happen at all
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
Security problems
Database systems offer solutions to all the above problems
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 name : string; street : string; city : integer; end;
View level: application programs hide details of data types. Views can also hide information (e.g., salary) for security purposes.
View of Data
An architecture for a database system
Instances and Schemas
Similar to types 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
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 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.
Data Models
A collection of tools for describing
data
data relationships
data semantics
data constraints
Entity-Relationship model
Relational model
Other models:
object-oriented model
semi-structured data models
Older models: network model and hierarchical model
Entity-Relationship Model
Example of schema in the entity-relationship model
Structure of a DBMS
A typical DBMS has a layered architecture.
The figure does not show the concurrency control and recovery components.
This is one of several possible architectures; each system has its own variations.
Query Optimization
and Execution
Relational Operators
Files and Access Methods
Buffer Management
Disk Space Management
DB
These layers
must consider
concurrency
control and
recovery
22
Why Study Databases??
Shift from computation to information
at the “low end”: access to physical world
at the “high end”: scientific applications
Datasets increasing in diversity and volume.
Digital libraries, interactive video, Human Genome project, e-commerce, sensor networks
... need for DBMS/data services exploding
DBMS encompasses several areas of CS
OS, languages, theory, AI, multimedia, logic
Example: University Database
Conceptual schema:
Students(sid: string, name: string, login: string,
age: integer, gpa:real)
Courses(cid: string, cname:string, credits:integer)
Enrolled(sid:string, cid:string, grade:string)
Physical schema:
Relations stored as unordered files.
Index on first column of Students.
External Schema (View):
Course_info(cid:string, enrollment:integer)
7
Fall 2002
14
Problem 1: Efficiency
Size of personal address book is probably less than one hundred entries, but there are things we'd like to do quickly and efficiently.
“Give me all appointments on 10/28”
“When am I next meeting Jim?”
“Program” these as quickly as possible.
Have these programs executed efficiently.
What would happen if you were using a corporate calendar with hundreds of thousands of entries?
Fall 2002
15
Problem 2. Concurrency and Reliability
Suppose other people are allowed access to your calendar and are allowed to modify it? How do we stop two people changing the file at the same time and leaving it in a physical (or logical) mess?
Suppose the system crashes while we are changing the calendar. How do we recover our work?
Data Manipulation Language (DML)
Language for accessing and manipulating the data organized by the appropriate data model
DML also known as query language
Two classes of languages
Procedural – user specifies what data is required and how to get those data
Nonprocedural – user specifies what data is required without specifying how to get those data
SQL is the most widely used query language
SQL
SQL: widely used non-procedural language
E.g. 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’
E.g. find the balances of all accounts held by the customer with customer-id 192-83-7465 select account.balance from depositor, account where depositor.customer-id = ‘192-83-7465’ and depositor.account-number = account.account-number
Application programs generally access databases through one of
Language extensions to allow embedded SQL
Application program interface (e.g. ODBC/JDBC) which allow SQL queries to be sent to a database
Database Users
Users are differentiated by the way they expect to interact with the system
Application programmers – interact with system through DML calls
Sophisticated users – form requests in a database query language
Specialized users – write specialized database applications that do not fit into the traditional data processing framework
Naïve users – invoke one of the permanent application programs that have been written previously
E.g. people accessing database over the web, bank tellers, clerical staff