The Relational Database Model
The Relational Database Model
The Relational Database Model The following are some conclusions based on the table above.
o The STUDENT table is composed of six (6)
Fundamentals rows/tuples and five (5) columns/attributes.
The relational model, introduced by E. F. Codd in 1970, is o Each of the six (6) rows describes a student. For
based on predicate logic and set theory. example, row 5 describes Martin S. Cruz.
o Predicate logic is used extensively in mathematics to o Because the STU_MI values are limited to
provide a framework in which an assertion characters A to Z, the domain is [A, Z].
(statement of fact) can be verified as either true or o STU_NUM is the primary key since it is guaranteed
false. unique for each student. STU_LNAME would not be
Example: A student with a student ID of 324452 is a good primary key because students can have the
named Mark Reyes. same last name. Same reason applies to other
o Set theory is a part of mathematical science that attributes.
deals with sets, or groups of things, and is used as Keys
the basis for data manipulation in the relational
model.
Example: Set A contains 15, 23, and 52 while Set B
contains 41, 52, 70, 12. It can be concluded that Table 1. STUDENT Table Attribute Values
the A and B share a common value, 52.
The relational model has three (3) components:
1. A logical data structure represented by relations
2. A set of integrity rules to enforce that the data is
consistent and remains consistent over time
3. A set of operations that defines how data is
manipulated
A table (relation) is as a two-dimensional structure
composed of rows and columns.
Each table row (tuple) represents data about an entity.
Each table column represents an attribute, and each
column has a distinct name.
Each intersection of a row and column represents a single
data value.
All values in a column must conform to the same data
format. Each column has a specific range of values known
as the attribute domain.
The order of the rows and columns is not important in a DBMS.
STU_NUM STU_LNAME STU_FNAME STU_MI STU_SECT
324452 Reyes Mark V IT101
324257 Velasco Marco R CS101
324258 Santos Markus D IS101
324273 dela Cruz Miguel C CS102
324299 Cruz Martin S IT101
324264
03 Handout 1 Santiago Matthew A IT102 *Property of STI
[email protected] Page 1 of 6
IT1924
A key is an attribute or group of attributes that
determines the values of other attributes. For
example, an invoice number identifies all of the
invoice attributes, such as the invoice date and the
customer name.
Determination is the state in which knowing the value
of an attribute makes it possible to determine the
value of another. It is based on the relationships
among the attributes.
Functional dependence means that the value of one or
more attributes determines the value of one or more
other attributes.
The attribute whose value determines another is
called the determinant or the key. The attribute whose
value is determined by the other attribute is called the
dependent.
The standard notation for representing the
relationship between attributes is: ATT_A → ATT_B
For example,
STU_NUM → STU_LNAME
STU_NUM is the determinant and STU_LNAME is the
dependent. When given a value for STU_NUM, you can
determine the value for STU_LNAME because only one
(1) value of STU_LNAME is associated with any given
value of STU_NUM.
Functional dependence can involve a determinant that
comprises multiple attributes.
For example,
STU_NUM → (STU_LNAME, STU_FNAME, STU_MI, STU_SECT)
A composite key is a key that is composed of more
than one attribute.
An attribute that is a part of a key is called a key attribute.
Integrity Rules
An entity integrity is the condition in which each row in a
table has its own unique identity.
A referential integrity is the conditional in which every
reference to an entity instance by another entity instance
is valid.
Integrity rules are followed to maintain a good database
design.
Entity Integrity Description
Requirement All primary key entries are unique, and no
part of a primary key may be null.
Purpose Each row will have a unique identity, and
foreign key values can properly reference
primary key values.
03 Handout 1 *Property of STI
[email protected] Page 3 of 6
IT1924
as it is not a part of its table’s primary key, or column has no null entries, and all entries are
an entry that matches the primary key unique. Similarly, the SECTIONS table’s primary key
value in a table to which it is related. is STU_SECT, and this primary key column is also
Every non-null foreign key value must free of null entries.
reference an existing primary key value.
Purpose It is possible for an attribute not to have a
corresponding value, but it will be
impossible to have an invalid entry.
The enforcement of the referential integrity
rule makes it impossible to delete a row in
one table whose primary key has
mandatory matching
foreign key values in another table.
Example A customer might not yet have an assigned
sales representative (number), but it will be
impossible to
have an invalid sales representative
(number).
Table name: STUDENTS
Primary key: STU_NUM
Foreign key: STU_SECT
STU_NUM STU_LNAME STU_FNAME STU_MI STU_SECT
324452 Reyes Mark V IT101
324257 Velasco Marco R
324258 Santos Markus IS101
324273 dela Cruz Miguel C CS102
324299 Cruz Martin IT101
324264 Santiago Matthew A IT102
Table name: SECTIONS
Primary key: STU_SECT
Foreign key: None
STU_SECT PROG_TITLE CURRICULUM_VER
CS101 BS in Computer Science BSCS-18-02
CS102 BS in Computer Science BSCS-18-02
IS101 BS in Information Systems
BSIS-19-01
IT101 BS in Information BSIT-19-02
Technology
IT102 BS in Information BSIT-19-02
Technology
The following are the features of the tables:
o Entity Integrity: The STUDENTS primary key (STU_NUM)
03 Handout 1 *Property of STI
[email protected] Page 4 of 6
IT1924
o Referential Integrity: The STUDENTS table contains a into a new table, dropping the
foreign key, STU_SECT, that links entries in the duplicate rows
STUDENTS table to the SECTIONS table. The Two or more tables that have the same number
STU_CODE row identified by the (primary key) of columns and the corresponding columns
number 324257 contains a null entry in its have compatible domains are
TABLE1 ∪ TABLE2
STU_SECT foreign key because Marco Velasco does union-compatible.
STUDENTS ∪ SECTIONS
not yet have a section assigned to him. The Syntax
remaining STU_SECT entries in the STUDENTS table Example
all match the STU_SECT entries in the SECTIONS INTERSECT Retrieves rows that are common to ∩
table. two
To avoid nulls, special codes called flags are used to union-compatible tables
indicate the absence of some value. For example, the Syntax TABLE1 ∩ TABLE2
code NS can be used as the STU_SECT entry in the second Example STUDENTS ∩ SECTIONS
row of the STUDENTS table to indicate that Marco DIFFERENCE Retrieves rows from one table that
Velasco's section does not yet have a section assigned to are not
him. If such a flag is used, the SECTIONS table must found in another union-compatible
contain a dummy row with a STU_SECT value of NS. table
Syntax TABLE1 – TABLE2
Relational Algebra Example STUDENTS – SECTIONS
Data can be manipulated to generate useful information. PRODUCT Retrieves possible pairs of rows from
Relational algebra is a set of mathematical principles that two tables (Cartesian Product)
form the basis for manipulating relational table contents. Syntax TABLE1 x TABLE2
𝔚
The use of relational algebra operators on existing Example STUDENTS x SECTIONS
relations (tables) produces new relations is called closure. JOIN Retrieves rows from two tables based
The condition to be evaluated is also known as predicate. on criteria (Ex. Rows with common
The eight (8) fundamental relational operators are: values in
TABLE1 𝔚 TABLE2
their common attributes)
Operator Description Symbol
STUDENTS 𝔚 SECTIONS
Syntax
SELECT Retrieves a subset of rows σ Example
Syntax σ CONDITION (TABLE) DIVIDE Retrieves values ÷
Example σ STU_NUM = 324452 (STUDENTS)
Syntax TABLE1 ÷ TABLE2
Output STU_NUM STU_LNAME STU_FNAME STU_MI STU_SECT
324452 Reyes Mark IT101 Example STUDENTS ÷ SECTIONS
PROJECT Retrieves a subset of columns π
Syntax π COLUMNS (TABLE)
Example π STU_FNAME, STU_LNAME (STUDENTS)
Output STU_FNAME STU_LNAME
Mark Reyes
Marco Velasco
Markus Santos
Miguel dela Cruz
Martin Cruz
References:
Coronel, C. and Morris, S. (2017). Database systems: design, implementation, and
management (12th ed.). USA: Cengage Learning.
Elmasri, R. and Navathe, S. (2016). Fundamentals of database systems (7th ed.).
USA: Pearson Higher Education.
Kroenke, D. and Auer, D. (2016). Database processing: fundamentals, design,
and implementation. England: Pearson Education Limited.