0% found this document useful (0 votes)
39 views10 pages

Week7 CM MDL CC225

Uploaded by

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

Week7 CM MDL CC225

Uploaded by

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

ASIAN INSTITUTE OF COMPUTER STUDIES

Bachelor of Science in Computer Science


Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

MODULE 7: ADVANTAGES OF RELATIONAL MODEL


WEEK 7

Learning Outcomes:
After completing this course you are expected to demonstrate the following:
1. Explain the advantages of relational model and rules for fully relational systems. It
also familiarize the learner with earlier database models.

A. Engage
BUBBLE ORGANIZER
Instruction: Using the bubble organizer, define the meaning of such word situated inside the
bubbles.

RELATIONAL

DATA DATA DATA


STRUCTURE MANIPULATION INTEGRITY

Figure 7.0

B. Explore

Video Title: Advantages of the Relational Model – Week 7


YouTube Link: https://www.youtube.com/watch?v=M6mWv9SPJz4
Module Video Filename: Module7 video – Advantages of the Relational Model

C. Explain
As previously discusses, relational model was proposed by E. F. Codd in 1970 and
consists of the following three components: (a) a data structure for building the database, (b)
data manipulation which is a collection of operators that may be used to retrieve, derive or
modify data stored in the database and (c) data integrity which is a collection of rules that
implicitly or explicitly define a consistent database state or changes of states.

Relational Model (RM) represents the database as a collection of relations. A relation


is nothing but a table of values. Every row in the table represents a collection of related data
values. These rows in the table denote a real-world entity or relationship.

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 1 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

D. Elaborate
Introduction
In the relational model, data are structured into tables (i.e., "relations") consisting of
rows and columns. Each row contains a single record comprised of individual data elements (or
"attributes") organized in columns containing elements of the same kind according to the rules
defined for that column. Alternate database models include the network and hierarchical.

Advantages of the Relational Model

Codd in his 1970 paper indicated that there were four major objectives in designing the
relational data model.
 Data Independence - to provide a sharp and clear boundary between the logical and
physical aspects of database management.
 Simplicity - to provide a simpler structure than were being used at that time. A simple
structure is easy to communicate to users and programmers and a wide variety of users
can interact with a simple model.
 Set-processing - to provide facilities for manipulating a set of records at a time so that
programmers are not operating on the database record by record.
 Sound Theoretical Background - to provide a theoretical background for database
management field.

Rules for Fully Relational Systems

Dr. Edgar Frank Codd (August 19, 1923 – April 18, 2003) was a computer scientist while
working for IBM he invented the relational model for database management (theoretical basis
for relational databases). Codd proposed thirteen rules (numbered zero to twelve) and said that
if a Database Management System meets these rules, it can be called as a Relational Database
Management System. These rules are called as Codd's 12 rules. Hardly any commercial product
follows all.

Rule Zero
The system must qualify as relational, as a database, and as a management system. For a
system to qualify as a relational database management system (RDBMS), that system must use
its relational facilities (exclusively) to manage the database.
The other 12 rules derive from this rule. The rules are as follows:
Rule 1: The information rule: All information in the database is to be represented in one and
only one way, namely by values in column positions within rows of tables.
Rule 2: The guaranteed access rule: All data must be accessible. This rule is essentially a
restatement of the fundamental requirement for primary keys. It says that every individual
scalar value in the database must be logically addressable by specifying the name of the
containing table, the name of the containing column and the primary key value of the
containing row.
Rule 3: Systematic treatment of null values: The DBMS must allow each field to remain null (or
empty). Specifically, it must support a representation of "missing information and inapplicable

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 2 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

information" that is systematic, distinct from all regular values (for example, "distinct from zero
or any other number", in the case of numeric values), and independent of data type. It is also
implied that such representations must be manipulated by the DBMS in a systematic way.
Rule 4: Active online catalog based on the relational model: The system must support an online,
inline, relational catalog that is accessible to authorized users by means of their regular query
language. That is, users must be able to access the database's structure (catalog) using the
same query language that they use to access the database's data.
Rule 5: The comprehensive data sub language rule: The system must support at least one
relational language that
1. Has a linear syntax
2. Can be used both interactively and within application programs,
3. Supports data definition operations (including view definitions), data manipulation
operations (update as well as retrieval), security and integrity constraints, and
transaction management operations (begin, commit, and rollback).
Rule 6: The view updating rule: All views those can be updated theoretically, must be updated
by the system.
Rule 7: High-level insert, update, and delete: The system must support set-at-a-time insert,
update, and delete operators. This means that data can be retrieved from a relational database
in sets constructed of data from multiple rows and/or multiple tables. This rule states that
insert, update, and delete operations should be supported for any retrievable set rather than
just for a single row in a single table.
Rule 8: Physical data independence: Changes to the physical level (how the data is stored,
whether in arrays or linked lists etc.) must not require a change to an application based on the
structure.
Rule 9: Logical data independence: Changes to the logical level (tables, columns, rows, and so
on) must not require a change to an application based on the structure. Logical data
independence is more difficult to achieve than physical data independence.
Rule 10: Integrity independence: Integrity constraints must be specified separately from
application programs and stored in the catalog. It must be possible to change such constraints
as and when appropriate without unnecessarily affecting existing applications.
Rule 11: Distribution independence: The distribution of portions of the database to various
locations should be invisible to users of the database. Existing applications should continue to
operate successfully :
1. when a distributed version of the DBMS is first introduced; and
2. when existing distributed data are redistributed around the system.
Rule 12: The non-subversion rule: If the system provides a low-level (record-at-a-time)
interface, then that interface cannot be used to subvert the system, for example, bypassing a
relational security or integrity constraint.

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 3 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

Earlier Database Models – Hierarchical and Network Models

In the days before the relational database model, two data models were commonly
used to maintain and manipulate data the hierarchical database model and the network
database model.

The Hierarchical Database Model


Data in this type of database is structured hierarchically and is typically diagrammed as an
inverted tree. A single table in the database acts as the "root" of the inverted tree and other
tables act as the branches flowing from the root. Figure 7.1 shows a diagram of a typical
hierarchical database structure.

Figure 7.1. Diagram of a typical hierarchical database


Agents Database
In the example shown in Figure 7.1, an agent books several entertainers, and each
entertainer has his own schedule. An agent also maintains a number of clients whose
entertainment needs are met by the agent. A client books engagements through the agent and
makes payments to the agent for his services.
A relationship in a hierarchical database is represented by the term parent/child. In this
type of relationship, a parent table can be associated with one or more child tables, but a single
child table can be associated with only one parent table. These tables are explicitly linked via
a pointer or by the physical arrangement of the records within the tables. A user accesses data
within this model by starting at the root table and working down through the tree to the target
data. This access method requires the user to be very familiar with the structure of the
database.
One advantage to using a hierarchical database is that a user can retrieve data very
quickly because there are explicit links between the table structures. Another advantage is
that referential integrity is built in and automatically enforced. This ensures that a record in a
child table must be linked to an existing record in a parent table, and that a record deleted in
the parent table will cause all associated records in the child table to be deleted as well.
A problem occurs in a hierarchical database when a user needs to store a record in a
child table that is currently unrelated to any record in a parent table. Consider an example using
the Agents database shown in Figure 7.1. A user cannot enter a new entertainer in the
ENTERTAINERS table until the entertainer is assigned to an agent in the AGENTS table. Recall
that a record in a child table (in this case, ENTERTAINERS) must be related to a record in the
parent table (AGENTS). Yet in real life, entertainers commonly sign up with the agency well
before they are assigned to specific agents. This scenario is difficult to model in a hierarchical

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 4 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

database. The rules can be bent without breaking them if a dummy agent record is inserted in
the AGENTS table; however, this option is not really optimal.
This type of database cannot support complex relationships, and there is often a
problem with redundant data. For example, there is a many-to-many relationship between
clients and entertainers; an entertainer will perform for many clients, and a client will hire
many entertainers. You can't directly model this type of relationship in a hierarchical database,
so you'll have to introduce redundant data into both the SCHEDULE and ENGAGEMENTS tables.
 The SCHEDULE table will now have client data (such as client name, address, and phone
number) to show for whom and where each entertainer is performing. This particular
data is redundant because it is currently stored in the CLIENTS table.
 The ENGAGEMENTS table will now contain data on entertainers (such as entertainer
name, phone number, and type of entertainer) to indicate which entertainers are
performing for a given client. This data is redundant as well because it is currently
stored in the ENTERTAINERS table.
The problem with this redundancy is that it opens up the possibility of allowing a user to
enter a single piece of data inconsistently. This, in turn, can result in producing inaccurate
information.
A user can solve this problem in a roundabout manner by creating one hierarchical
database specifically for entertainers and another specifically for agents. The
new Entertainers database will contain only the ENTERTAINERS table, and the
revised Agents database will contain the AGENTS, CLIENTS, PAYMENTS, and ENGAGEMENTS
tables. The SCHEDULE table is no longer needed in the Entertainers database because you can
define a logical child relationship between the ENGAGEMENTS table in the Agents database and
the ENTERTAINERS table in the Entertainers database. With this relationship in place, you can
retrieve a variety of information, such as a list of booked entertainers for a given client or a
performance schedule for a given entertainer. Figure 1.2 shows a diagram of the new model.

Figure 7.2. Using two hierarchical databases to resolve a many-to-many relationship


As you see, a person designing a hierarchical database must be able to recognize the
need to use this technique for a many-to-many relationship. Here the need is relatively obvious,
but many relationships are more obscure and may not be discovered until very late in the
design process or, more disturbingly, well after the database has been put into operation.
The hierarchical database lent itself well to the tape storage systems used by
mainframes in the 1970s and was very popular in companies that used those systems. But,
despite the fact that the hierarchical database provided fast and direct access to data and was

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 5 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

useful in a number of circumstances, it was clear that a new database model was needed to
address the growing problems of data redundancy and complex relationships among data.

The Network Database Model


The network database was, for the most part, developed as an attempt to address some of the
problems of the hierarchical database. The structure of a network database is represented in
terms of nodes and set structures. Figure 7.3 shows a diagram of a typical network database.

Figure 7.3. Diagram of a typical network database


Agents Database
In the example shown in Figure 7.3, an agent represents a number of clients and
manages a number of entertainers. Each client schedules any number of engagements and
makes payments to the agent for his or her services. Each entertainer performs a number of
engagements and may play a variety of musical styles.
A node represents a collection of records, and a set structure establishes and represents
a relationship in a network database. It is a transparent construction that relates a pair of nodes
together by using one node as an owner and the other node as a member. (This is a valuable
improvement on the parent/child relationship.) A set structure supports a one-to-many
relationship, which means that a record in the owner node can be related to one or more
records in the member node, but a single record in the member node is related to only
one record in the owner node. Additionally, a record in the member node cannot
exist without being related to an existing record in the owner node. For example, a
client must be assigned to an agent, but an agent with no clients can still be listed in the
database. Figure 7.4 shows a diagram of a basic set structure.

Figure 7.4. A basic set structure

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 6 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

One or more sets (connections) can be defined between a specific pair of nodes, and a
single node can also be involved in other sets with other nodes in the database. In Figure 7.3,
for instance, the CLIENTS node is related to the PAYMENTS node via the Make set structure. It is
also related to the ENGAGEMENTS node via the Schedule set structure. Along with being
related to the CLIENTS node, the ENGAGEMENTS node is related to the ENTERTAINERS node via
the Perform set structure.
A user can access data within a network database by working through the appropriate
set structures. Unlike the hierarchical database, where access must begin from a root table, a
user can access data from within the network database, starting from any node and working
backward or forward through related sets. Consider the Agents database in Figure 7.3 once
again. Say a user wants to find the agent who booked a specific engagement. She begins by
locating the appropriate engagement record in the ENGAGEMENTS node, and then determines
which client "owns" that engagement record via the Schedule set structure. Finally, she
identifies the agent that "owns" the client record via the Represent set structure. The user can
answer a wide variety of questions as long as she navigates properly through the appropriate
set structures.
One advantage the network database provides is fast data access. It also allows users to
create queries that are more complex than those they created using a hierarchical database. A
network database's main disadvantage is that a user has to be very familiar with the structure
of the database in order to work through the set structures. Consider the Agents database in
Figure 7.3 once again. It is incumbent on the user to be familiar with the appropriate set
structures if she is to determine whether a particular engagement has been paid. Another
disadvantage is that it is not easy to change the database structure without affecting the
application programs that interact with it. Recall that a relationship is explicitly defined as a set
structure in a network database. You cannot change a set structure without affecting the
application programs that use this structure to navigate through the data. If you change a set
structure, you must also modify all references made from within the application program to
that structure.
Although the network database was clearly a step up from the hierarchical database, a
few people in the database community believed that there must be a better way to manage
and maintain large amounts of data. As each data model emerged, users found that they could
ask more complex questions, thereby increasing the demands made upon the database. And so,
we come to the relational database model.

Summary:

 Dr. Edgar Frank Codd was a computer scientist who proposed thirteen rules (numbered zero
to twelve) and said that if a Database Management System meets these rules, it can be
called as a Relational Database Management System.
 Codd in his 1970 paper indicated that there were four major objectives in designing the
relational data model: data independence, simplicity, set-processing and sound theoretical
background.
 Two data models were commonly used to maintain and manipulate data the hierarchical
database model and the network database model.
 A node represents a collection of records, and a set structure establishes and represents a
relationship in a network database.
 The network database was, for the most part, developed as an attempt to address some of
the problems of the hierarchical database.

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 7 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

E. Evaluate

ASSESSMENT:
Instruction: Answer the questions below. Write your answer in the Answer Sheet (AS)
provided for 2 points each.

IDENTIFICATION:

_________________1. It represents a collection of records, and a set structure establishes


and represents a relationship in a network database.
_________________2. It provides a simpler structure than were being used at that time to
easily communicate to users and programmers and a wide variety of users can interact with
a simple model.
_________________3. Data in this type of database is structured hierarchically and is
typically diagrammed as an inverted tree.
_________________4. Codd proposed thirteen rules (numbered zero to twelve) and said
that if a Database Management System meets these rules, it can be called as a
_________________.
_________________5. This network database was, for the most part, developed as an
attempt to address some of the problems of the hierarchical database.

REVIEW QUESTIONS:
Enumerate and explain the advantages of relational model. (5 points each)

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 8 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

Hands-On Activity 7.1

 Dealing with an Apostrophe


Some characters that are input by a user can cause a page to stop working. It is recommended
to try this experiment to learn about escaping (converting) problem characters. Problem
characters are characters that act as both code and text—for instance, an apostrophe is text,
but to PHP it is also code because it signifies the start and finish of a piece of text. Escaping the
apostrophe tells PHP that the problem character is not to be treated as code. Try registering the
following new member using the details in Table 7-1. His name contains an apostrophe that will
halt the script:
Table 7-1. Register a member who has an apostrophe in his name

Because O’Brien contains an apostrophe, you will receive an error message and the page will
halt. PHP assumes that the apostrophe is code; therefore, the page stops when it arrives at the
unexpected apostrophe.

The function mysqli_real_escape_string($dbcon, $variable); was used in the last example,


register-password.php. If we add this function to the registration file register-page.php, it will
allow users to enter names with apostrophes.

Open your htdocsfolder, and save a copy of register-page.php with the new name register-
page-apos.php. This is a backup in case you mess up the original page.
In the new file register-page-apos.php, find this line:

else { $ln = trim($_POST['lname']);


}

Change the line to


else {$ln = mysqli_real_escape_string($dbcon, trim($_POST['lname']))
;
}
IMPORTANT: The new function will work only if the language encoding is utf-8 and the
database connection is opened before the function is called. The language is already set to utf-8
in the database connection file and within the meta tag (shown in bold). Next, in the file
register-page-apos.php, move the database connection line require ('mysqli_connect.php') to
the start of the PHP code. This is shown in bold in the partial listing for the registerpage-
apos.php file. The file is not included in the downloads because it is assumed that you will
create it, a part of the code is given in the next snippet.

Listing A Snippet Showing the Amendments to the Registration Page (register-page-apos.php)

<!doctype html>
<html lang=en>
<head>
<title>Register page for apostrophes</title>
<meta charset=utf-8><!--important for escaping problem
characters-->
<link rel="stylesheet" type="text/css" href="includes.css">
</head>

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 9 of 10
ASIAN INSTITUTE OF COMPUTER STUDIES
Bachelor of Science in Computer Science
Course Modules
CC225 - Information Management (Database System)
2nd Year – 2nd Semester

<body>
<div id="container">
<?php include("header.php"); ?>
<?php include("nav.php"); ?>
<?php include("info-col.php"); ?>
<div id="content"><!-- Registration handler content starts here -
->
<p>
<?php
//The link to the database is moved here to the top of the PHP
code.
require ('mysqli_connect.php'); // Connect to the db.
// This query INSERTs a record in the users table.

Scroll down to find the piece of code listed next, and change the line as shown in bold type:
// Check for a last name:
if (empty($_POST['lname'])) {
$errors[] = 'You forgot to enter your last name.';
} else {
$ln = mysqli_real_escape_string($dbcon, trim($_POST['lname']));
}

Scroll down to find the piece of code listed next, and delete the line shown in bold type (or, as I
have done, add two forward slashes to the front of the line to comment it out):
//Start of the SUCCESSFUL SECTION. i.e all the fields were filled
out
if (empty($errors)) { // If everything's OK, register the user in
the database
//require ('mysqli_connect.php'); // Connect to the database.

References:
1. Lecture Notes on Relational Model
https://www.guru99.com/relational-data-model-dbms.html
https://www.w3resource.com/sql/sql-basic/codd-12-rule-relation.php
http://etutorials.org/SQL/Database+design+for+mere+mortals/Part+I+Relational+Datab
ase+Design/Chapter+1.+The+Relational+Database/Early+Database+Models/
2. West, A. W. (2013). Practical PHP and MySQL Web Site Databases: A Simplified
Approach, ISBN-13 (electronic): 978-1-4302-6077-6

Facilitated By:

Name :

MS Teams Account (email) :

Smart Phone Number :

Prepared and Validated By: Ms. Almira Sacriz | Dean Manuel Luis C. Delos Santos, MSCS Page 10 of 10

You might also like