03 Handout 1 (13) (1) Unlocked
03 Handout 1 (13) (1) Unlocked
The Relational Database Model • The following are some conclusions based on the table above.
o The STUDENT table is composed of six (6) rows/tuples and
Fundamentals five (5) columns/attributes.
• The relational model, introduced by E. F. Codd in 1970, is based o Each of the six (6) rows describes a student. For example,
on predicate logic and set theory. row 5 describes Martin S. Cruz.
o Predicate logic is used extensively in mathematics to o Because the STU_MI values are limited to characters A to
provide a framework in which an assertion (statement of Z, the domain is [A, Z].
fact) can be verified as either true or false. o STU_NUM is the primary key since it is guaranteed unique
Example: A student with a student ID of 324452 is named for each student. STU_LNAME would not be a good primary
Mark Reyes. key because students can have the same last name. Same
o Set theory is a part of mathematical science that deals with reason applies to other attributes.
sets, or groups of things, and is used as the basis for data
manipulation in the relational model. Keys
Example: Set A contains 15, 23, and 52 while Set B • A key is an attribute or group of attributes that determines the
contains 41, 52, 70, 12. It can be concluded that the A and values of other attributes. For example, an invoice number identifies
B share a common value, 52. all of the invoice attributes, such as the invoice date and the
• The relational model has three (3) components: customer name.
1. A logical data structure represented by relations • Determination is the state in which knowing the value of an
2. A set of integrity rules to enforce that the data is consistent attribute makes it possible to determine the value of another. It is
and remains consistent over time based on the relationships among the attributes.
3. A set of operations that defines how data is manipulated • Functional dependence means that the value of one or more
• A table (relation) is as a two-dimensional structure composed of attributes determines the value of one or more other attributes.
rows and columns. • The attribute whose value determines another is called the
• Each table row (tuple) represents data about an entity. determinant or the key. The attribute whose value is determined
• Each table column represents an attribute, and each column has by the other attribute is called the dependent.
a distinct name. • The standard notation for representing the relationship between
• Each intersection of a row and column represents a single data attributes is: ATT_A → ATT_B
value. For example,
• All values in a column must conform to the same data format. Each STU_NUM → STU_LNAME
column has a specific range of values known as the attribute STU_NUM is the determinant and STU_LNAME is the dependent. When
domain. given a value for STU_NUM, you can determine the value for
• The order of the rows and columns is not important in a DBMS. STU_LNAME because only one (1) value of STU_LNAME is associated
STU_NUM STU_LNAME STU_FNAME STU_MI STU_SECT with any given value of STU_NUM.
324452 Reyes Mark V IT101 • Functional dependence can involve a determinant that comprises
324257 Velasco Marco R CS101 multiple attributes.
324258 Santos Markus D IS101 For example,
324273 dela Cruz Miguel C CS102 STU_NUM → (STU_LNAME, STU_FNAME, STU_MI, STU_SECT)
324299 Cruz Martin S IT101 • A composite key is a key that is composed of more than one
324264 Santiago Matthew A IT102 attribute.
Table 1. STUDENT Table Attribute Values • An attribute that is a part of a key is called a key attribute.
• The types of keys are the following: as it is not a part of its table’s primary key, or an
Key Type Description entry that matches the primary key value in a table
Superkey An attribute or combination of attributes that to which it is related.
uniquely identifies any row in the table Every non-null foreign key value must reference an
Example STU_NUM and any combination with STU_NUM existing primary key value.
Ex. (STU_NUM, STU_LNAME) Purpose It is possible for an attribute not to have a
(STU_NUM, STU_FNAME, STU_SECT) corresponding value, but it will be impossible to
Candidate Key A superkey without any unnecessary attributes have an invalid entry.
Example STU_NUM The enforcement of the referential integrity rule
Primary Key A candidate key selected to uniquely identify all makes it impossible to delete a row in one table
other attribute values in any given row; cannot whose primary key has mandatory matching
contain null entries. foreign key values in another table.
Example STU_NUM Example A customer might not yet have an assigned sales
representative (number), but it will be impossible to
Foreign Key An attribute or combination of attributes in one table have an invalid sales representative (number).
whose values must either match the primary key in
another table or be null. Table name: STUDENTS
Example STU_SECT can be a foreign key if it is used as a Primary key: STU_NUM
primary key of another table. Foreign key: STU_SECT
Secondary Key An attribute or combination of attributes used strictly STU_NUM STU_LNAME STU_FNAME STU_MI STU_SECT
for data retrieval purposes. 324452 Reyes Mark V IT101
Example (STU_LNAME, STU_FNAME, STU_MI) 324257 Velasco Marco R
324258 Santos Markus IS101
324273 dela Cruz Miguel C CS102
Integrity Rules
324299 Cruz Martin IT101
• An entity integrity is the condition in which each row in a table has
its own unique identity. 324264 Santiago Matthew A IT102
• A referential integrity is the conditional in which every reference to Table name: SECTIONS
an entity instance by another entity instance is valid. Primary key: STU_SECT
• Integrity rules are followed to maintain a good database design. Foreign key: None
STU_SECT PROG_TITLE CURRICULUM_VER
Entity Integrity Description
CS101 BS in Computer Science BSCS-18-02
Requirement All primary key entries are unique, and no part of a
CS102 BS in Computer Science BSCS-18-02
primary key may be null.
IS101 BS in Information Systems BSIS-19-01
Purpose Each row will have a unique identity, and foreign
key values can properly reference primary key IT101 BS in Information Technology BSIT-19-02
values. IT102 BS in Information Technology BSIT-19-02
Example No invoice can have a duplicate number, nor can it • The following are the features of the tables:
be null; in short, all invoices are uniquely identified o Entity Integrity: The STUDENTS primary key (STU_NUM)
by their invoice number. column has no null entries, and all entries are unique.
Referential Integrity Description Similarly, the SECTIONS table’s primary key is STU_SECT,
Requirement A foreign key may have either a null entry, as long and this primary key column is also free of null entries.