39
Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Embed Size (px)

Citation preview

Page 1: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Chapter 9Database Systems

Introduction to CS

1st Semester, 2015 Sanghyun Park

Page 2: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Outline Database Fundamentals Data Models Relational Model Object-Oriented Databases (skip) Maintaining Database Integrity Traditional File Structures Data Mining (skip) Social Impact of Database Technology (skip)

Page 3: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Database Fundamentals A database is a collection of data that is ________, not

necessarily physically, _________ A database management system (_______) defines,

creates, and maintains a database The DBMS also allows users _________ access to data

in the database relying on schemas and subschemas A ________ is a description of the entire database

structure used by the DBMS A __________ is a description of only that portion of the

database ________ to a particular user’s needs Databases have evolved as a means of _________

data storage systems

Page 4: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

File vs. Database Organization (1/2)

_________ data ___________ problem

Page 5: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

File vs. Database Organization (2/2)

Page 6: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Layered Approach toDatabase Implementation

A typical database system consists of ____ layers –an _________ layer and a database management layer

Advantages of this dichotomy Allows for the construction and use of _________ tools Provides a means for controlling access to the databases Achieves data _____________

Page 7: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Database Models A database model defines the _______ design of data

The model also describes the ____________ between different parts of data

In the history of database design, three models have been in use: Hierarchical model Network model Relational model

Page 8: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Hierarchical Model Data are organized as a ____ Each entity has only ___ parent but can have several

children

Page 9: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Network Model Entities are organized in a _____, where some

entities can be accessed through _______ paths There is __ hierarchy

Page 10: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Relational Model (1/2) Data are organized in two-dimensional ______

called _________ There is no hierarchical or network structure imposed on

the data

Page 11: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Relational Model (2/2) Each column in a relation is called an _________

The total number of attributes for a relation is called the ______ of the relation

Each row in a relation is called a _____

The total number of rows in a relation is called the __________ of the relation

The cardinality of a relation changes when tuples are added or deleted; this makes the database _________

Page 12: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Issues of Relational Design (1/4)

Lack of efficiency due to __________ Possibility of information ____ when deleting a tuple The source of the problems is that we have combined

more than one concept into a ______ relation

Page 13: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Issues of Relational Design (2/4)

Page 14: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Issues of Relational Design (3/4) ASSIGNMENT relation

Job Id Start Date Term Date

S25XF5

S25Z

3-1-199910-1-2001

5-1-2001

4-30-2001*

*

This database contains information about employees in EMPLOYEE relation, about available jobs in JOB relation, and about job history in ASSIGNMENT relation

Additional information is implicitly available by ________ the information from _________ relations

Page 15: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Issues of Relational Design (4/4) Finding the department in which employee 23Y34 has

worked

Page 16: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Relational Operations: SELECT

Page 17: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Relational Operations: PROJECT

Page 18: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Relational Operations: JOIN (1/3)

Page 19: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Relational Operations: JOIN (2/3)

Page 20: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Relational Operations: JOIN (3/3)

Page 21: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Issues of Implementation The data in a database are actually stored in a ____

storage system A DBMS allows the application software to be written in

terms of a ______________ It is the duty of the ______ to accept commands in

terms of the relational _____ and convert them into actions relative to the actual storage structure

The simplest way for a DBMS to implement a relation is to store it as a __________ file

To provide rapid access to entries, the DBMS would store the relation as an _______ file or utilize ________ techniques

Page 22: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Structured Query Language (1/2) The language called ____ (Structured Query Language)

is used extensively by application software programmers for manipulating databases

A query involving a combination of SELECT, PROJECT, and JOIN operations can be expressed as a _____ SQL statement

We should read a SQL statement as a description of the information ______ rather than a _________ of activities to be performed not procedural but __________

Page 23: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Structured Query Language (2/2) SELECT statement

select EMPLOYEE.Name, ASSIGNMENT.StartDatefrom EMPLOYEE, ASSIGNMENTwhere EMPLOYEE.EmplId = ASSIGNMENT.EmplId

INSERT statementinsert into EMPLOYEEvalues (‘42Z12’, ‘Sue A. Burt’, ‘33 Fair St.’, ‘444661111’)

DELETE statementdelete from EMPLOYEEwhere Name = ‘G. Jerry Smith’

UPDATE statementupdate EMPLOYEEset Address = ‘1812 Napoleon Ave.’where Name = ‘Joe E. Baker’

Page 24: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Maintaining Database Integrity (1/2)

___________ is a sequence of operations that must all happen together (e.g., money transfer between accounts)

Before a transaction is allowed to alter the database,the alteration to be performed is first recorded in the ___

The point at which all the steps in a transaction have been recorded in the log is called the ____________

At this point DBMS becomes ________ to the transaction

If problems arise before a transaction has reached its commit point, the log can be used to _______ (undo) the activities actually performed by the transaction

Page 25: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Maintaining Database Integrity (2/2)

Simultaneous access problems Incorrect summary problem Lost update problem

______ is used for preventing others from accessing data being used by a transaction Shared lock is used when ________ data Exclusive lock is used when _________ data

Page 26: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Traditional File Structures A ___ is an external collection of related data treated as

a unit

The primary purpose of a file is to _____ data

Files are stored in what are known as ________ or _________ storage devices such as disk and tape

For our purposes, a file is a collection of data _______ with each record consisting of one or more _____

The _____ method determines how records can be retrieved: sequentially or randomly

Page 27: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Taxonomy of File Structures

Page 28: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Sequential Files

While Not EOF{

Read the next recordProcess the record

}

Page 29: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Applications of Sequential Files The sequential file is used in applications that need to

access ___ records from beginning to end

For example, if personal information about each employee is stored in a file, we can use sequential access to retrieve each record at the end of the monthto print the paychecks

The sequential file is not efficient for _______ access

Page 30: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Indexed Files To access a record in a file randomly, we need to know

the _______ of the record

An indexed file is made of a data file, which is a sequential file, and an _____

The index itself is a very ____ file with only two fields: the ___ of the sequential file and the ________ of the corresponding record on the disk

Page 31: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Mapping in an Index File

Page 32: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Logical View of an Indexed File

Page 33: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Hashed Files In an indexed file, the index _____ the key to the

address; A hashed file uses a ________ to accomplish this mapping

The hashed file eliminates the need for an ____ file(index)

However, we will see that hashed files have their own problems

Page 34: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Modulo Division Hashing Method

Page 35: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Collision (1/2) The population of keys is greater than the ______ of

records in the data file

Because there are many keys for each address in the file, there is a possibility that more than one key will hash to the _____ address in the file

We call the set of keys that hash to the same address ________

A _______ is the event that occurs when a hashing algorithm produces an address for an insertion key, and that address is already occupied

Page 36: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Collision (2/2)

Page 37: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Collision Resolution: Open Addressing

Page 38: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Collision Resolution:Linked List Resolution

Page 39: Chapter 9 Database Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park

Collision Resolution: Bucket Hashing