Chapter 3
Chapter 3
DATABASE MODEL
CHRIS MARK C. AQUINO
THE CONCEPT OF DATA TYPES IN A
RELATIONAL DATABASE MODEL
1. Simple Data Types. This includes basic validation and formatting
requirements placed on to individual values 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 Floating points
Fixed – length decimals Dates and times
DATA TYPES ACCORDING TO COMPLEXITY
1. 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.
KEYS COMMONLY USED IN RDM
2. 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.
KEYS COMMONLY USED IN RDM
3. 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.
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.
INTEGRITY RULES
1. 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.
TYPES OF RELATIONAL SET
OPERATORS
2. PROJECT
– This relational operator yields all values for
selected attributes. In other words, PROJECT
yields a vertical subset of a table.
TYPES OF RELATIONAL SET
OPERATORS
3. 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.
TYPES OF RELATIONAL SET
OPERATORS
4. 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.
TYPES OF RELATIONAL SET
OPERATORS
5. 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.
TYPES OF RELATIONAL SET
OPERATORS
5. PRODUCT
This relational operator yields all possible
pairs of rows from two tables also known as
the Cartesian product.
TYPES OF RELATIONAL SET
OPERATORS
6. 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 DATA DICTIONARY?