0% found this document useful (0 votes)
33 views28 pages

Chapter 3 Module 3 Cc105

Uploaded by

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

Chapter 3 Module 3 Cc105

Uploaded by

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

Chapter 3

THE RELATIONAL
DATABASE MODEL
Prepared by:
PATRICK Q. RAMOS, MIT
Objectives:
 At the end of this chapter, the students should be able
to:
 Understand the concept of relations as the relational
model’s basic component.
 Understand the characteristics of a relational table.
 Know the different data types applicable to the
relational database model.
 Know the concept keys in a relational database model
and how each keys may differ from one another.
THE LOGICAL VIEW OF THE
RELATIONAL DATABASE MODEL
 The idea of the relational database model is that data in a specific table is directly
associated with all other items in that same table. The logical view of the relational
database model is facilitated by the creation of data relationships based on a logical
construct known as a relation. Because a relation is a mathematical construct, end
users find it much easier to think of a relation as a table.
 A table is perceived as a two – dimensional structure composed of rows and columns.
A table is also called a relation because the relational model’s creator, E. F. Codd,
used the term relation as a synonym for table. It was based on the mathematical set
theory from which Codd derived his model. Because the relational model uses
attribute values to establish relationships among tables, many database users
incorrectly assume that the term relation refers to such relationships. Many then
incorrectly conclude that only the relational model permits the use of relationships.
Table 1 shows the characteristics of a table in lieu of
the relational database model.

Table 1. Characteristics of Relational Table


Figure 8 shows the illustration a relational table’s
characteristics as listed in Table 1.

Figure 8. Curriculum Table Attribute Values


THE CONCEPT OF DATA TYPES IN A
RELATIONAL DATABASE MODEL
 A data type comprises the forms data can take inside
the database. There are many different types of data
types, which vary often more in name than anything
else with respect to different to DBMS software.
 They can be divided into three separate categories:
 Simple Data Types. This includes basic validation
and formatting requirements placed on to individual
values (this will also discussed in details on Chapter 4).
Simple data types may also be sub – categorized into the
following:
 Strings. A string is a sequence of one or more
characters. Strings can be fixed – length strings in
which it will always store the specified length declared
for that data type. They can be also variable – fixed
length strings in which it allows storage into a data type
as the actual length of string, as long as a maximum
limit is not exceeded.

 Numbers. Numeric data types are often the most


numerous field data types in many database tables. Here
are some of them:

 Integers
 Fixed – length decimals
 Floating points
 Dates and times
 Complex Data Types. This encompasses object data types.
Available object data types vary for different relational
databases. Some relational databases provide more object
– relational attributes and functionality than others.
Complex data types include any data types breaching the
object – relational database divide including items such as
binary objects, reference pointers, collection arrays and
even the capacity to create user – defined types.

 Specialized Data Types. These are present in more


advanced relational databases catering to inherently
structured data such as XML documents, spatial data,
multimedia objects and even dynamically definable data
types.
WHAT IS A KEY?
 A key consists of one or more attributes that
determine other attributes in a relational table. In
relational databases, keys are important because
they are used to ensure that each row in a table is
uniquely identifiable. They are also used to
establish relationships among tables and to ensure
the integrity of the data. Therefore, a proper
understanding of the concept and use of keys in
the relational model is very important.
WHAT ARE THE TYPE OF KEYS COMMONLY
USED IN A RELATIONAL DATABASE?
 The following keys are often found on relational
tables in which they play important roles to the
functionality on the whole relational database:
 Primary Key. It is used to uniquely identify a record
in a table. Unique identification for each record is
critical because there is no other way to find a record
without the possibility of finding more than one
record, if the said unique identifier is not used. A
primary key can be also used to define relationships
between tables.
 Candidate Keys. Sometimes called as a unique
key, it is created on a field containing only unique
values throughout the entire table similar to a primary
key. However, candidate keys are not used to define
relationships between tables compare to primary
keys. They only ensure uniqueness across a table.

 Foreign Keys. They are copies of primary keys


created into child tables to form the opposite side of
the link in an inter – table relationship in which it
establishes a “relational database relation”. A foreign
key defines the reference for each record in the child
table, referencing back to the primary key in the
parent table.
Figure 9. Illustration on the Use of Primary and Foreign Keys
WHAT IS DATA INTEGRITY?
 In a relational database, data integrity refers to a condition in
which the data in the database is in compliance with all entity
and referential integrity constraints. The integrity of data is the
validity of data, wherein possible compromises to data integrity
include human error at data entry, network transmission errors,
software bugs and virus infections, hardware malfunction, disk
errors, and natural disasters.
 To counter these compromises to data integrity, the most
significant prevention mechanisms are regular database
backups, computer security in all forms, and a properly
designed interfaces restricting how data is entered by data users.
INTEGRITY RULES
Relational database integrity rules are very important
to good database design. Many (but by no means all)
RDBMSs enforce integrity rules automatically.
However, it is much safer to make sure that your
application design conforms to the entity and
referential integrity rules as shown in Table 2.
Table 2. Entity and Referential Integrity Rules
 From Figure 8, the following features can be established
based from the entity and referential integrity rules from
Table 2:
 In terms of entity integrity, the Curriculum table’s primary
key is SUBJ_ENT_ID. Notice that the Curriculum table’s
primary key column has no null entries and all entries are
all unique. Similarly, the Subject_Offering table’s primary
key is SUBJ_CODE, and its column is all free of null
entries.

 In terms of referential integrity, the Curriculum table


contains a foreign key, SUBJ_CODE that links entries in the
Curriculum table to the Subject_Offering table.
 Basically,primary and foreign keys automatically
verify against each other. Primary and foreign key
references are the connections establishing and
enforcing referential integrity between tables.

 On the other hand, a table’s primary key should never


have null values or duplicate entries. That is because
each row in the table should have a unique identity that
will be based from the table’s primary key.
RELATIONAL SET
OPERATORS
 The data in relational tables are of limited value
unless the data can be manipulated to generate
useful information. Relational algebra defines the
theoretical way of manipulating table contents
using the following relational operators that are
typically implemented using the Structured Query
Language:
 SELECT – also known as RESTRICT, it yields values for all rows found in a table
that satisfy a given condition. SELECT can be used to list all of the row values, or
it can yield only those row values that match a specified criterion. In other words,
SELECT yields a horizontal subset of a table.

Figure 10. SELECT Relational Operator Illustration


 PROJECT – This relational operator yields all values for selected attributes. In
other words, PROJECT yields a vertical subset of a table.

Figure 11. PROJECT Relational Operator Illustration


 UNION – It combines all rows from two tables, excluding duplicate rows. The
tables must have the same attribute characteristics which included the columns
and domains must be compatible to be used in the UNION. When two or more
tables share the same number of columns, and when their corresponding columns
share the same or compatible domains, they are said to be union – compatible.

Figure 12. UNION Relational Operator Illustration


 INTERSECT – This relational operator yields only the rows that appear in both
tables. As was true in the case of UNION, the tables must be union – compatible
to yield valid results. For example, the INTERSECT relation operator cannot be
used if one of the attributes is numeric and one is character – based.

Figure 13. INTERSECT Relational Operator Illustration


 DIFFERENCE – DIFFERENCE yields all rows in one table that are not found in
the other table; that is, it subtracts one table from the other. As was true in the
case of UNION, the tables must be union – compatible to yield valid results.

Figure 14. SELECT Relational Operator Illustration


 PRODUCT – This relational operator yields all possible pairs of rows from two
tables also known as the Cartesian product.

Figure 15. PRODUCT Relational Operator Illustration


 JOIN – JOIN allows information to be combined from two or more tables. JOIN is
the real power behind the relational database, allowing the use of independent
tables linked by common attributes. Types of JOIN implementation can be
explained further through the utilization of SQL during data manipulation queries.
WHAT IS A DATA
DICTIONARY?
 A data dictionary generally provides a detailed
description of all tables found within the created
database made by the database designer.
 Thus, the data dictionary contains at least all of
the attribute names and characteristics for each
table in the system. In short, the data dictionary
contains metadata that typically describes the
“data about the data” as shown in Figure 16.
Figure 16. A Sample Data Dictionary from a single database
Jeremiah 29:11
 For I know the plans I have for you, declares the
Lord, plans for welfare and not for evil, to give
you a future and a hope.

You might also like