0% found this document useful (0 votes)
7 views44 pages

Week 11

Chapter 9 of 'Computer Science: An Overview' discusses database systems, highlighting the differences between traditional file systems and databases, as well as the role of schemas and database management systems (DBMS). It covers relational and object-oriented database models, operations such as SELECT and JOIN, and the importance of maintaining database integrity through transactions. Additionally, it addresses traditional file structures, indexing, hashing, and the concept of data mining.

Uploaded by

ahubieva920
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views44 pages

Week 11

Chapter 9 of 'Computer Science: An Overview' discusses database systems, highlighting the differences between traditional file systems and databases, as well as the role of schemas and database management systems (DBMS). It covers relational and object-oriented database models, operations such as SELECT and JOIN, and the importance of maintaining database integrity through transactions. Additionally, it addresses traditional file structures, indexing, hashing, and the concept of data mining.

Uploaded by

ahubieva920
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 44

Computer Science An Overview

13th Edition, Global Edition

Chapter 9
Database Systems

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


9.1 Database Fundamentals
Database: A collection of data that is multidimensional in
the sense that internal links between its entries make the
information accessible from a variety of perspectives
•This is in contrast to a traditional file system, sometimes called a
flat file, which is a one-dimensional storage system, meaning that it
presents its information from a single point of view.

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.1 A file versus a database
organization

Such integrated pools of information provided a valuable resource with which


management decisions could be made, assuming the information could be accesse
in a meaningful way .
Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.
The Role of Schemas
• Schema: A description of the structure of an entire
database, used by database software to maintain the
database
• Subschema: A description of only that portion of the
database pertinent to a particular user’s needs, used to
prevent sensitive data from being accessed by
unauthorized personnel

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Database Management Systems
• Database Management System (DBMS): A software
layer that manipulates a database in response to
requests from applications
• Distributed Database: A database stored on multiple
machines
– DBMS will mask this organizational detail from its
users
• Data independence: The ability to change the
organization of a database without changing the
application software that uses it

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Database Management Systems
• Database Management System (DBMS):Database
management systems provide yet another example.
• They hide the complexities of a database’s internal structure,
allowing the user of the database to imagine that the information
stored in the database is arranged in a more useful format.

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.2 The conceptual layers of a
database implementation

an application layer (The application software handles the communication


with the
user of the database) and a database management layer

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.2 The conceptual layers of a
database implementation

Note that the application software does not directly manipulate


the database.
The actual manipulation of the database is accomplished by the
database management system (DBMS)
Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.
Figure 9.2 The conceptual layers of a
database implementation

application software has determined what action the user is requesting, it


uses the DBMS as to obtain the results. If the request is to add or delete
data, it is the DBMS that actually
alters the database. If the request is to retrieve information, it is the DBMS
that
performs the required searches.Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.
Database Models
• DBMS contains routines that translate commands stated in
terms of a conceptual view of the database into the actions
required by the actual data storage system.

• A conceptual view of a database Database model:


– Relational database model
– Object-oriented database model

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


9.2 The Relational Model
• Relation: In the case of the relational database model, the
conceptual view of the database is that of a collection of
tables consisting of rows and columns.
• For example, information about a company’s employees might be
viewed as a table containing a row for each employee and
columns labeled name, address, employee identification number,
and so on

• A rectangular table
– Attribute: A column in the table. Columns in a
relation are referred to as attributes
– Tuple: A row in the table

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.3 A relation containing employee
information

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Issues of Relational Design
• Avoid multiple concepts within one relation
– Can lead to redundant data
– Deleting a tuple could also delete necessary but
unrelated information

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.5 An employee database
consisting of three relations

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.6 Finding the departments in
which employee 23Y34 has worked

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Relational Operations
• SELECT: Choose rows
• PROJECT: Choose columns
• JOIN: Assemble information from two or more relations

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.8 The SELECT operation

perform on a relation is to select tuples possessing certain characteristics and to


place these selected tuples in a new relation.

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.9 The PROJECT operation

In contrast to the SELECT operation, which extracts rows from a relation, the
PROJECT operation extracts columns

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.10 The JOIN operation

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.11 Another example of the JOIN
operation

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.12 An application of the JOIN
operation

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Structured Query Language (SQL)
• Thus a DBMS based on the relational model would include routines
to perform the SELECT, PROJECT, and JOIN operations which could
then be called from the application software.

• Operations to manipulate tuples


– insert
– update
– delete
– select

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


SQL Examples
• SELECT EmplId, Dept
FROM Assignment, Job
WHERE Assignment.JobId = Job.JobId
AND Assignment.TermData = '*';

• INSERT INTO Employee


VALUES ('43212', 'Sue A. Burt',
'33 Fair St.', '444661111');

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


SQL Examples (continued)
• DELETE FROM Employee
WHERE Name = 'G. Jerry Smith';

• UPDATE Employee
SET Address = '1812 Napoleon Ave.'
WHERE Name = 'Joe E. Baker';

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


9.3 Object-oriented Databases
• Object-oriented Database: A database constructed by
applying the object-oriented paradigm
– Each entity stored as a persistent object
– Relationships indicated by links between objects
– DBMS maintains inter-object links

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.13 The associations between
objects in an object-oriented database

classes (types of objects): EMPLOYEE, JOB, and


ASSIGNMENT. An object from the EMPLOYEE class could
contain such entries as EmplId, Name, Address,
and SSNum;
an object from the class JOB could contain such entries as
JobId, JobTitle, SkillCode, and Dept;

object from the class ASSIGNMENT


could contain entries such as StartDate and TermDate.
Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.
9.4 Maintaining Database Integrity
• Transaction: A sequence of operations that must all
happen together
– Example: transferring money between bank accounts
• Transaction log: A non-volatile record of each
transaction’s activities, built before the transaction is
allowed to execute
– Commit point: The point at which a transaction has
been recorded in the log
– Roll-back: The process of undoing a transaction

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Maintaining database integrity (continued)
• Simultaneous access problems
– Incorrect summary problem
– Lost update problem
• Locking: preventing others from accessing data being
used by a transaction
– Shared lock: used when reading data
– Exclusive lock: used when altering data

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


9.5 Traditional File Structures
• Sequential file: A sequential file is a file that is accessed in a
serial manner from its beginning to its end as though the
information in the file were arranged in one long row.
• Examples include audio files, video files, files containing
programs, and files containing textual documents.

• Reader must be able to detect end-of-file (EOF)


– Data can be stored in logical records, sorted by a key
field

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.14 The structure of a simple
employee file implemented as a text file

The data in a sequential file must be recorded in mass storage in


such a way that the sequential nature of the file is preserved.

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.14 The structure of a simple
employee file implemented as a text file

The final file would be a long string of encoded characters in which each
31-character block represents the information about a single
employee

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.14 The structure of a simple
employee file implemented as a text file

Information would be retrieved from the file in terms of logical records


consisting of 31-character blocks.
Within each of these blocks, individual fields would be identified
according to the uniform format with which the blocks were
Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.
constructed.
Figure 9.15 A function for merging two
sequential files
def MergeFiles (InputFileA, InputFileB, OutputFile):
if (both input files at EOF):
Stop, with OutputFile empty
if (InputFileA not at EOF):
Declare its first record to be its current record
if (InputFileB not at EOF):
Declare its first record to be its current record
while (neither input file at EOF):
Put the current record with the “smaller” key field value in OutputFile
if (that current record is the last record in its corresponding input file):
Declare that input file to be at EOF
else:
Declare the next record in that input file to be the file’s current record
Starting with the current record in the input file that is not at EOF,
copy the remaining records to OutputFile

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.16 Applying the merge algorithm
(Letters are used to represent entire records. The
particular letter indicates the value of the
record’s key field.)

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Indexed Files
• Index: A list of key values and the location of their
associated records
– Efficient way to quickly identify the location of a
desired record
– Index is stored as a separate file

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Indexed Files
• Index: Sequential files are ideal for storing data that will be
processed in the order in which the file’s entries are stored.
However, such files are inefficient when records within the file
must be retrieved in an unpredictable order.

• Efficient way to quickly identify the location of a desired


record
• Index file is file’s index is normally stored as a separate file on
the same mass storage device as the indexed file.

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.17 Opening an indexed file

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Hash Files
• Although indexing provides relatively quick access to entries
within a data storage
• structure, it does so at the expense of index maintenance.

• Hashing is a technique that provides similar access without such


overhead.

• hashing allows a record to be located by means of a key value.


But, rather than looking up the key in an index, hashing identifies
the location of the record directly from the key.

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Hash Files
• Each record has a key field
• The storage space is divided into buckets
• A hash function computes a bucket number for each
key value
• Each record is stored in the bucket corresponding to
the hash of its key

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Hash Files
• Hashing is not only used as a means of retrieving data from mass
storage but also as a means of retrieving items from large
blocks of data stored in main memory.
• When hashing is applied to a storage structure in mass storage, the
result is called a hash file. When applied to a storage structure
within main memory, the result is usually called a hash table.

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Figure 9.18 Hashing the key field value
25X3Z to one of 41 buckets

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Hash Files
• Later, if we need to retrieve a record, we need merely apply our
hash function to
• the record’s key to identify the appropriate bucket and then
search that bucket
• for the record in question..

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


Collisions in Hashing
• Collision: The case of two keys hashing to the same
bucket
– Major problem when table is over 75% full
– Solution: increase number of buckets and rehash all
data

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.


9.6 Data Mining
• Data Mining: The area of computer science that deals
with discovering patterns in collections of data
• Data warehouse: A static data collection to be mined
– Data cube: Data presented from many perspectives
to enable mining

Copyright © 2019 Pearson Education, Ltd. All Rights Reserved.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy