2. Text Book
• Database System Concepts 6th
Edition, Abraham Silberschatz,
et al, McGraw-Hill
• Additional reading: Connolly, T.
M. (2005). Database Systems: A
Practical Approach to Design,
Implementation, and
Management, (4th Ed.), Essex:
Addison Wesley
Note: you must have the printed copy of the book
3. Course Structure
1. Introduction to DBMS (week 1)
2. File Organization (week 2)
3. Indexing and Hashing (week 3-4)
4. Query Processing and Optimization (week 5-6)
5. Transactions (week 7)
6. OO DBMS, XML (week 8-9)
7. DB Architectures, parallel, distributed DB (week
10-12)
8. Advanced Application Development (week 13)
4. Class Activity
• 70% theory
• 30% hands-on assignments
– Students will work in pairs (2 students each group)
– Each group to prepare A MS Windows 7/8 laptop
5. Assessment
• 35% Group work & individual homework
• 30% Mid-term Tests
• 35% Final Exam
• Minimum 80% class attendance
6. Class Rules
• Class normally starts at 7:30 and stops at 9:10 (but
there might be times that it will start at 7:20)
• Attendance check will be done at 7:45 – I cannot
accept excuses such as “macet”, “cannot find parking
spot” or “flat tyre”
• No phones inside the class – tablets are OK but do not
use them for social media or chat
• If anytime you feel you need to go to the washroom, or
make a phone call outside, please do so – no need to
ask for my permission
• English to be used at all times
• Please sit in the front rows whenever possible
• Please dress professionally
8. What is A Database?
• Is an organized collection of data
• Computer program can quickly select the
desired pieces of data
• Typically a database is organized by:
– Fields (=single piece of information)
– Records (=complete set of fields)
– Files (=collection of records)
9. Data is Produced …
• Each time you make a phone
call or send messages
• Each time you withdraw
money from an ATM
• Each time you purchase a
merchandise in a retail shop
• Each time you book an airline
ticket
• ..and many many more
Picture source: google.com
10. An Example – call detail record
• The telephone number of the
caller and the calling partner
• The time when the conversation
started
• How long the call lasted
• How much the cost
• What cell tower identification
was serving the caller
6282346376766 +6285334692755 2014/02/01 00:26:20.0 63 500 510101630030573
6282291065057 +6285259187902 2014/02/01 00:49:25.0 430 2000 510100910840061
6285367034197 +6281354260056 2014/02/01 00:51:23.0 163 750 510100917165221
6282198087732 +6282292261026 2014/02/01 00:13:12.0 54 250 510101221640754
6281360050554 +6282372171347 2014/02/01 00:28:50.0 391 1750 510100980136873
6282170311008 +6282238722355 2014/02/01 00:44:29.0 104 500 510100036500045
A telecommunication company could generate hundreds of million of such records in a day!
freepatentsonline.com
field
record
11. Database Management System
(DBMS)
• DBMS contains information about a particular organization:
– Collection of interrelated data
– Set of programs to access the data
– An environment that is both convenient and efficient to use
• Database Applications:
– Banking: transactions
– Airlines: reservations, schedules
– Universities: registration, grades
– Sales: customers, products, purchases
– Online retailers: order tracking, customized recommendations
– Manufacturing: production, inventory, orders, supply chain
– Human resources: employee records, salaries, tax deductions
• Databases touch all aspects of our lives
• Databases can be very large.
13. University Database Example
• Application program examples
– Add new students, instructors, and courses
– Register students for courses, and generate class
rosters
– Assign grades to students, compute grade point
averages (GPA) and generate transcripts
• In the early days, database applications were
built directly on top of file systems
14. Drawbacks of Using File Systems
• 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 must be > 0)
become “buried” in program code rather than being stated
explicitly
– Hard to add new constraints or change existing ones
15. Drawbacks of using file systems to store
data (Cont.)
– Atomicity of updates
• Failures may leave database in an inconsistent state with partial updates carried out
• Example: Transfer of students should either complete or not happen at all
– Concurrent access by multiple users
• Concurrent access needed for performance
• Uncontrolled concurrent accesses can lead to inconsistencies
– Example: Two people reading a balance (say 100) and updating it by withdrawing
money (say 50 each) at the same time
– Security problems
• Hard to provide user access to some, but not all, data
Database systems offer solutions to all the above problems
Database systems provide abstract view of the data
17. Levels of Abstraction
• Physical level: describes how a record (e.g., customer) is
stored.
• Logical level: describes what data stored in database, and
the relationships among the data.
type instructor = record
ID : string;
name : string;
dept_name : string;
salary : integer;
end;
• View level: application programs hide details of data
types. Views can also hide information (such as an
employee’s salary) for security purposes.
18. Instances and Schemas
• Similar to types and variables in programming languages : schema is when
variables are declared, instance is when the program is run
• 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 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.
19. Data Models
• A collection of tools for describing
– Data
– Data relationships
– Data semantics
– Data constraints
• Categories:
1. Relational model
2. Entity-Relationship data model (mainly for database
design)
3. Object-based data models (Object-oriented and Object-
relational)
4. Semistructured data model (XML)
• Other older models:
– Network model
– Hierarchical model
20. Relational Model
• Relation = table = file
• Tuples = rows = Records.
• Column = field
• Example of tabular data in the relational model: Columns
Rows
(Tuples)
22. How to Access The Data
• Use these languanges:
1. DML
2. DDL
23. Data Manipulation Language (DML)
• Language for accessing and manipulating the
data organized by the appropriate data model
– DML also known as query language
• Query = request to retrieve some information
• Two classes of languages
– Procedural – user specifies what data is required
and how to get those data
– Declarative (non-procedural) – user specifies
what data is required without specifying how to
get those data – easier to learn
• SQL is the most widely used non-procedural
query language
24. Data Definition Language (DDL)
• Specification notation for defining the database schema
Example: create table instructor (
ID char(5),
name varchar(20),
dept_name varchar(20),
salary numeric(6))
• DDL compiler generates a set of table templates stored in a data dictionary
• Data dictionary contains metadata (data about data)
– Database schema
– Integrity constraints
• Primary key (ID uniquely identifies instructors)
• Referential integrity (references constraint in SQL)
– e.g. dept_name value in any instructor tuple must appear in department relation
– Authorization
25. SQL
• SQL: widely used non-procedural language
– Example: Find the name of the instructor with ID 22222
select name
from instructor
where instructor.ID = ‘22222’
– Example: Find the ID and building of instructors in the Physics dept.
select instructor.ID, department.building
from instructor, department
where instructor.dept_name = department.dept_name and
department.dept_name = ‘Physics’
• 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
• Chapters 3, 4 and 5
26. Database Design
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
28. Yes, Many Problems
• Redundant/repetition of tuples : so many
departments are repeated
• Waste of space
• Complicates updates on the table : if we want
to change a budget of a department, many
tuples must be changed
• Cannot create new department unless at least
one instructor is present in the department
29. Design Approaches
• Normalization Theory
– Dividing large tables into smaller ones, and
defining the relationships between them
– Reduce repetitions
– Isolates data, thus inserts/deletes/updates
can be made in just one table
• Entity Relationship Model
– An abstract way to describe a database
30. The Entity-Relationship Model
• Models an enterprise as a collection of entities and relationships
– Entity: a “thing” or “object” in the organization that is
distinguishable from other objects
• Described by a set of attributes
– Relationship: an association among several entities
• Represented diagrammatically by an entity-relationship
diagram:
1..10..*
31. Individual Homework #1
• Name one IT application you find in your daily life
that uses DBMS
– What it does and how it works
– What information is stored in the DBMS
• What tables (each with its column names) might be there
• Estimated size of the data (number of records)
• You may use your own assumptions as needed
• Submit your paper via LMS in PDF or XPS format
• Deadline : Tuesday March 11, 23:59 WIB
32. Object-Relational Data (ORD) Models
• Relational model: flat, “atomic” values
• Object Relational Data Models:
– Extend the relational data model by including object
orientation and constructs to deal with added data types
– Adapt OOP concepts: Encapsulation, object/classes,
inheritance
– Allow attributes of tuples to have complex types,
including non-atomic values such as nested relations
– Preserve relational foundations, provide upward
compatibility with existing relational languages
33. Object Data Type
• Object contains :
– Attributes
– Methods
Source: Oracle.com
35. Objects (cont’d)
“person_typ” is now a data type, can be used just like any other kind of
data type :
Attributes and methods of the object are accessed using the dot (“.”) :
Source: Oracle.com
36. XML: Extensible Markup Language
• Defined by the WWW Consortium (W3C)
• Originally intended as a document markup
language, not a database language
• The ability to specify new tags, and to create nested
tag structures made XML a great way to exchange
data, not just documents
• XML has become the basis for all new generation
data interchange formats.
• A wide variety of tools is available for parsing,
browsing and querying XML documents/data –
example: XPath, XQuery language
38. Example of XML Application
Web Service
ProviderDBMS Applications
Data exchanged
in XML format
39. Main Components of A DBMS
1. Query Processor
– Provide simplified access to the data
– Handle queries
2. Storage Manager
– Interfaces with the operating system
40. Storage Management
• 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 (operating system files)
– Efficient storing, retrieving and updating of data
– Translates DML into file system commands
• Issues it must handle:
– Storage access
– File organization
– Indexing and hashing
41. Query Processing
1. Parsing and translation – check syntax, validate tables & attributes,
translate into relational algebra
2. Optimization – finds the most efficent execution plan (which index is
used, join algorithms, cost estimation)
3. Evaluation – executes the plan against the actual data and get the
results
43. Query Processing (Cont.)
• Cost difference between a good and a bad way
of evaluating a query can be enormous
• Cost factors: disk I/O access needed, seek time
required, CPU load, number of tuples affected
• Need to estimate the cost of operations
– Depends critically on statistical information about
relations which the database must maintain
– Need to estimate statistics for intermediate results
to compute cost of complex expressions
44. Transactions
• Example: transferring $100 from a bank
account to another account in a different bank
1. The sender’s account must be deducted by $100
2. Then, the $100 fund is added to the destination
account
• What if the system fails during the operation?
• What if more than one user is concurrently
updating the same data?
45. Transaction Management
• A transaction is a collection of operations that
performs a single logical function in a database
application
• Atomicity : All operations must be performed or none
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.
• Concurrency-control manager controls the interaction
among the concurrent transactions, to ensure the
consistency of the database.
46. Database Users and Administrators
Database
Access to database via Query Processor
48. Database Architecture
The architecture of a database systems is
greatly influenced by the underlying
computer system on which the database is
running:
• Centralized
• Client-server (2-tier, 3-tier)
• Parallel (multi-processor)
• Distributed
51. Data Warehouse, Data Mining
• Data warehouse:
– Data is gathered from multiple transaction
systems in an organization
– Especially designed for query / data retrieval,
reporting, and analysis
• Data Mining:
– Find useful patterns inside large sets of data
– Uses artificial intelligence
52. History of Database Systems
• 1950s and early 1960s:
– Data processing using magnetic tapes for storage
• Tapes provided only sequential access
– Punched cards for input
• Late 1960s and 1970s:
– Hard disks allowed direct access to data
– Network and hierarchical data models in widespread
use
– Dr. Edgar F. Codd defined the relational data model
• IBM Research begins System R prototype
• UC Berkeley begins Ingres prototype
– High-performance (for the era) transaction processing
53. History (cont.)
• 1980s:
– Research relational prototypes evolve into commercial systems
• SQL becomes industrial standard
– Parallel and distributed database systems
– Object-oriented database systems
• 1990s:
– Large decision support and data-mining applications
– Large multi-terabyte data warehouses
– Emergence of Web commerce
– Object-Relational DBMS
• Early 2000s:
– XML and XQuery standards
– Automated database administration
• Later 2000s:
– Giant data storage systems with massive parallel processing
• Oracle Exadata, Teradata, Greenplum, Google BigTable, Yahoo PNuts, ..