DARYL B.
VALDEZ, MIT
Instructor I
i
Preface
Course Number CS 221
Course Title
DATABASE SYSTEMS (Info Mgt) (MySQL)
Course Description
The course covers discussion of database systems, the nature of the data,
data association, data semantics and data models. A specific DBMS will be
used to implement data models for use in business application programs.
Credit Units 3 Number of hours 90
Semester Offered Second Semester
Overall Aim
This course aims to provide you with an understanding of the main issues
related to data storage and manipulation – the object of database systems. In
particular, this course is aimed at the detailed presentation of the theory and
practice of the relational model, on one side, and at the introduction of the
emerging trends in database systems, on the other. You will also gain practical
experience in a database language – MySQL – and in developing relational
database systems, through the activities and coursework assignments that you
will undertake.
Objectives
To provide the student with clear conceptual understandings related to
databases. After this course, the student should gain knowledge in the
relational model, SQL, database design, storage & indexing, failure recovery
and concurrency control.
Course Requirements
To successfully complete the course, you are required to perform/conduct all
the learning activities specified in each unit to the satisfaction of the facilitator.
Overall assessment of the outputs will be based on the following:
Unit Weight (%)
I
II
ii
III
IV
Total 100
iii
Table of Contents
Unit 1: Databases-Basic Concepts.....................................................................1
What is Database?.......................................................................................................2
Learning Activity........................................................................................................... 2
Topic 2.......................................................................................................................... 2
Learning Activity........................................................................................................... 2
Topic 3.......................................................................................................................... 2
Learning Activity........................................................................................................... 2
Topic 4.......................................................................................................................... 2
Learning Activity........................................................................................................... 2
Unit 2: TITLE..........................................................................................................3
Topic 1.......................................................................................................................... 4
Learning Activity........................................................................................................... 4
Topic 2.......................................................................................................................... 4
Learning Activity........................................................................................................... 4
Topic 3.......................................................................................................................... 4
Learning Activity........................................................................................................... 4
Topic 4.......................................................................................................................... 4
Learning Activity........................................................................................................... 4
Topic 5.......................................................................................................................... 4
Learning Activity........................................................................................................... 4
Unit 3: TITLE..........................................................................................................5
Topic 1.......................................................................................................................... 6
Learning Activity........................................................................................................... 6
Topic 2.......................................................................................................................... 6
Learning Activity........................................................................................................... 6
Topic 3.......................................................................................................................... 6
Learning Activity........................................................................................................... 6
Topic 4.......................................................................................................................... 6
Learning Activity........................................................................................................... 6
Topic 5.......................................................................................................................... 6
Learning Activity........................................................................................................... 6
Unit 4: TITLE..........................................................................................................7
iv
Topic 1.......................................................................................................................... 8
Learning Activity........................................................................................................... 8
Topic 2.......................................................................................................................... 8
Learning Activity........................................................................................................... 8
Topic 3.......................................................................................................................... 8
Learning Activity........................................................................................................... 8
Topic 4.......................................................................................................................... 8
Learning Activity........................................................................................................... 8
Topic 5.......................................................................................................................... 8
Learning Activity........................................................................................................... 8
References.............................................................................................................9
v
Unit 1: Databases – Basic Concepts
Introduction
This chapter considers some basic concepts of databases, what they are and
their advantages and/or disadvantages before introducing data modelling and
relational theory.
Aim
The aims of this chapter are to give you an overview of databases, explain their
components, introduce the architecture of a database system, consider what a
database management system is, before explaining data modelling theory and
defining its place within the context of database systems.
Learning Objectives
By the end of this chapter, and having completed the Essential readings and
activities, you should be able to:
• discuss the limitations of the file-based approach
• describe the way the database approach overcomes the limitations of the
• file-based approach
• define and explain what is meant by a database system and a database
• management system (DBMS)
• describe the three-level ANSI/SPARC architecture of a database system
• discuss the schemas and mappings corresponding to the three level
ANSI/
• SPARC architecture
• discuss the concept of data independence
• explain the role of each of the components of a database system – data,
• hardware, software and users
• present the most important features of a DBMS
• discuss the advantages and disadvantages of database systems
• discuss issues related to distributed database systems
• explain what a data modelling theory (or data model) is and define its
• place within the context of database systems.
Topics
What is a database?
The first – and most obvious – question to ask when you take up this subject is
the simplest – ‘What is a database?’ Certainly, you will have dealt with them,
indirectly, almost daily. Whether you are in a shop in person or whether you are
exploring its catalogue on the internet, when you check whether a product is in
stock, it is likely that a database will be used somewhere within the system.
Amazon and Facebook, YouTube and iTunes all use databases to deliver
products and services to their users. The database and its structure may be quite
obvious to the user for a library catalogue or an online retailer, but it may also be
serving a less direct purpose, allowing the company to keep track of its
employees and suppliers, or helping an advertiser track visitors to web pages
across different sites, tailoring their adverts to match a browser’s activity.
Activity
Before you read on, try to list some other examples of databases you have come across.
What do they have in common? Based on your examples, write down what you think are
the most important features of a database.
A database system is a system that stores data. To qualify as a database
system,
there are some features that it would have to offer:
• find (retrieve) data
• add (insert) new data
• delete unwanted data
• change (update) data.
•
This definition will be refined and formalized in the sections to come, but first,
we can illustrate these features with an example.
Consider a shoe shop, specializing in trainers. The shop keeps information
about the products it sells. This information could be organized in the form of
a table, as shown in Figure 2.1 (prices are in U.K. pounds sterling, shown as £),
and could be part of the shop’s database
Figure 2.1. A part of a shoe shop’s database of trainers.
The ‘Vans Ferris’ range is about to be discontinued, and the shop will no longer
have them for sale once the pair in stock is sold. At that point, the record for that
shoe – the row in the table – will be deleted.
‘Kaplan Mesh’ shoes have not been selling well, and the large number in stock
2
is taking up space, so the price will be reduced to £40. The corresponding field
for the price of that product – a cell in this table – will be updated.
A new fashion trainer, the ‘Asics Gel Lyte VI’ has just been released, so a new
record – a new row in the table – must be inserted. In this example, we would
expect several new records – for different sizes of shoe – to be inserted, but we
will only show one, to save space.
Figure 2.2 shows the table after these operations – deletion, updating and
insertion – have been carried out.
Figure 2.2. Part of the shoe shop’s database after some changes. Altered
fields are underlined.
A database has a structure and content. The structure is represented in this
example by the table headings; the content by the body of the table. The content
changes in time – it is dynamic in nature. The structure can change, but it is far
less changeable than the content. For instance, you could add a new column to
this table – the type of trainer or the activity it might be associated with – but you
would not expect to make such changes that often. The structure of the database
is called its intension and the content is called its extension (we will return to this
in more detail later in this chapter).
Although it may not be obvious from this example, a database is capable of
storing a large amount of data. So far, a database system is, for us, nothing more
than a system that manages data. But is any system that manages data a
database system? Is there anything that all database systems have in common,
that distinguishes them from other software systems? The answer is obviously
yes. In order to understand the ‘database approach’, we shall first have a brief
look at file-based systems. In appearance (behaviour) they are similar to
database systems, but they are conceptually (qualitatively) different. We shall
identify the drawbacks of the file-based approach to data management and then
introduce the database approach as a solution to most of these drawbacks.
Activity
3
Consider the database examples you listed in the previous activity. For each one, think
about it as a table like the ones in Figures 2.1 and 2.2 above. What columns would the
table have? Would all the information fit in a single table, or would there be several?
File-based systems
We shall start with a definition of file-based systems.
Definition: A file-based system is a collection of application programs, each
managing its own data.
In a file-based system, permanent data is stored in various files of ad-hoc
structures. Each application program defines and handles its own data files
independently of the others. This approach is called the de-centralized approach.
Each application program works with its data at the physical level, manipulating
records as they are organized in persistent memory. Sharing of data between
applications is likely to be limited.
The concept of a physical level for data is one to which we will return later. The
structure we describe is not purely physical, but we use the term to indicate that it
is to some extent platform dependent, because access to files is made through
the primitives (built-in functionality) of the operating system.
Take, for example, an estate agent’s office, for which we shall consider the Sales
and the Contracts department. Each department maintains its own data in its
own data files, as depicted in Figure 2.3.
4
The Sales Department needs:
• detailed information about the properties for rent, so staff can give good
• advice to customers (such as Type and No Of Rooms from the Property
for
• rent file);
• detailed information about customers, so that their needs can be
• appropriately matched to what is available (such as Preferred Type and
• Max Rent in the Renter file);
• ‘identification’ information – such as name, address and telephone number
– about customers, the properties on offer and their owners.
The Contracts Department needs:
• detailed information about the renting contracts (in the Lease file);
• identification’ information – such as name, address, telephone number –
about customers, the contracted properties and their owners.
Some drawbacks of this solution are obvious. These are the limitations of the
file-based approach in general. The most important are enumerated below.
Duplication. Different applications might have to make use of the same
information. Because each application has its own files, data is duplicated (e.g.
the ‘identification’ information in our example). This aspect has at least two
negative consequences. Firstly, duplication is wasteful.1 Secondly, data can
become inconsistent – it can have different values in different files (belonging
to
different applications), even though it is supposed to give the same piece of
information. For example, the address of an owner, Mr. J. Morris, might be
updated in the Owner file belonging to the Sales Department, while the
Contracts
Department might still have Mr. Morris’s old address.
Separation and isolation. Data is scattered among different files, each file
belonging to a certain department. A department has access to its own files,
but
no access to the files of the other departments. Files belonging to different
departments cannot be used together in order to create more complex data or
analysis. Often, because they are based on different infrastructures (platforms,
development software, etc.) files belonging to different departments cannot be
5
transferred (copied) across.
Program-data dependence. Each file belongs to a certain application
program. The (physical) structure of data is defined inside the application
program. This could easily – and usually does – lead to incompatible file
formats between applications, meaning that it becomes impossible to share
data between them. Another aspect is that data definition is embedded in the
application program. That means that if the physical structure of data is to be
changed – for instance, if instead of representing a year with two digits, it is to
be represented with four2 – then the application program itself must be
changed. Not only that, but the methods of access and manipulation of data
are also embedded in the application program (for instance, in previously-
defined queries); to change them, the application program must be modified.
In the file-based approach, the emphasis is placed on functionality – provided by
the application program. Data modelling takes a lower priority. This approach
leads to the drawbacks we have listed. If the approach is inverted and we
consider data as central, then these problems can be removed. Informally, this
represents the database approach.
Databases and database management systems
Database. ‘A database is a (shared) collection of logically-related persistent
data (including its description) as part of the information system of an
organization.’
Let us now explain this definition. A database is a large repository of data, in
which data is defined once and stored once. Data that was scattered in different
files – with different formats and owners – in the file-based approach, is now
integrated with minimum redundancy (duplication), as a single resource. Different
application programs will share this common resource, usually concurrently (at
the same time).
There are times when redundant data is necessary, some of which will be
explored in this guide. You might choose to store intermediate results that are
called for often (using snapshots) or to ensure the atomicity of a set of operations
(transactions). In these cases, the redundant data is intentionally included to
achieve something extra, and even so requires special treatment. The diagrams
in
6
Figure 2.4 and Figure 2.5 illustrate the differences between the database
approach and the file-based approach.
In the database approach (see Figure 2.5), the raw data is integrated in a
common database for all applications. The data is managed by a database
management system (DBMS), which provides shared access to it, for all the
applications in the system.
A database management system is a software system that provides a set of
primitives (built-in functionality) for defining, accessing and maintaining a
database.
A database stores both the raw data and its description. We say that the
information3 stored in a database is self-describing. The description of the raw
data is known as the system dictionary, data dictionary or metadata.
The consequence of this approach is program-data independence. This means
that the structure of data may change without affecting the application programs
7
that use it. This basic definition is going to be refined and better explained later in
this chapter.
This approach – separating the data definition from application programs – is
similar to data abstraction in programming, where the internal definition of an
object is kept separate from its external definition. An outside system can only
see the exterior of the object. As far as the external definition remains
unchanged, any changes in the object’s internal definition do not affect the
outside system.
A database management system automatically performs a lot of the
housekeeping tasks that would otherwise be the responsibility of the application
programmer. As a result, the user – i.e. the person who defines and uses the
database – is presented with a clean and powerful set of tools for database
development and exploitation. A more detailed description of both database
systems and database management systems is provided in the following
sections. At this stage, it is important that you broadly understand why database
systems are needed and what their main benefits are.
This definition, with its distinction between file-based and database approaches
is quite high-level and functional. From the discussion above, many organizations
that use database software would still be defined as having a file-based system,
if different departments use different database implementations for storing similar
data.
Activity
Before you read on, try to think of an organization you know – perhaps one you’ve
worked for or studied at – that has multiple systems similar to what is described above.
What problems can occur when you have data duplication like this? Does it matter
whether the separate systems store their information in database software or
spreadsheets? Do you think this is a useful definition of database systems?
8
Assessment
Your performance in this unit will be evaluated on the basis of your ability to
perform each learning activity in this unit. The criteria for grading your activities
are as follows;
Criteria Percent (%)
Total
The breakdown of points/weights for each activity is as follows:
Learning Activity Total Score Weights
Total 100
Contents
Topic 1
Learning Activity
Topic 2
Learning Activity
Topic 3
Learning Activity
9
Topic 4
Learning Activity
Topic 5
Learning Activity
Unit 2: TITLE
Introduction
Aim
Learning Objectives
10
Topics
Assessment
Your performance in this unit will be evaluated on the basis of your ability to
perform each learning activity in this unit. The criteria for grading your activities
are as follows;
Criteria Percent (%)
Total
The breakdown of points/weights for each activity is as follows:
Learning Activity Total Score Weights
Total 100
Contents
Topic 1
Learning Activity
Topic 2
Learning Activity
Topic 3
Learning Activity
11
Topic 4
Learning Activity
Topic 5
Learning Activity
Unit 3: TITLE
Introduction
Aim
Learning Objectives
12
Topics
Assessment
Your performance in this unit will be evaluated on the basis of your ability to
perform each learning activity in this unit. The criteria for grading your activities
are as follows;
Criteria Percent (%)
Total
The breakdown of points/weights for each activity is as follows:
Learning Activity Total Score Weights
Total 100
Contents
Topic 1
Learning Activity
Topic 2
Learning Activity
Topic 3
Learning Activity
13
Topic 4
Learning Activity
Topic 5
Learning Activity
Unit 4: TITLE
Introduction
Aim
Learning Objectives
14
Topics
Assessment
Your performance in this unit will be evaluated on the basis of your ability to
perform each learning activity in this unit. The criteria for grading your activities
are as follows;
Criteria Percent (%)
Total
The breakdown of points/weights for each activity is as follows:
Learning Activity Total Score Weights
Total 100
Contents
Topic 1
Learning Activity
Topic 2
Learning Activity
Topic 3
Learning Activity
15
Topic 4
Learning Activity
Topic 5
Learning Activity
References
16
Vision
A premier Science and Technology university for the formation of a
world class and virtuous human resource for sustainable
development in Bohol and the country.
Mission
BISU is committed to provide quality higher education in the arts
and sciences, as well as in the professional and technological
fields; undertake research and development, and extension
services for sustainable development of Bohol and the country.
Goals
1. Pursue faculty and education excellence and strengthen the
current viable curricular programs and develop curricular
programs that are responsive to the demands of the times both
in the industry and the environment.
2. Promote quality research outputs that respond to the needs of
the local and national communities.
3. Develop communities through responsive extension programs.
4. Adopt efficient and profitable income generating projects /
enterprise for self-sustainability.
5. Provide adequate, state-of-the-art and accessible infrastructure
support facilities for quality equation.
6. Promote efficient and effective good governance supportive of
high-quality education.
17
Bohol Island State University