Chap1 - Relational Model
Chap1 - Relational Model
Chapter Outline
violations
Relational Model Concepts
Represents data as a collection of relations
Table of values
or
Tuple t=<(age,34),(name,Harsha),(rollno,2)>
3. Values and NULLs in the Tuples
Each value in a tuple is atomic
NULL values, which are used to represent the values of
attributes that may be unknown or may not apply to a tuple
For example some STUDENT tuples have NULL for their office
phones because they do not have an office
Another student has a NULL for home phone
In general, we can have several meanings for NULL values, such
as value unknown, value exists but is not available, or
attribute does not apply to this tuple (also known as value
undefined).
4.Interpretation (Meaning) of a Relation
The relation schema can be interpreted as a declaration or a
type of assertion.
For example, the schema of the STUDENT relation asserts that,
in general, a student entity has a Rollno ,Name and Age.
Each tuple in the relation can then be interpreted as a
particular instance of the assertion.
For example, the first tuple asserts the fact that there is a
STUDENT whose Name is Vinay, Rollno is 3 and Age is 32.
Relational Model Notation
Constraints
Derived from the rules in the miniworld that the database represents
Characters
Booleans
t1[SK]≠ t2[SK]
- Underline attribute
Other candidate keys are designated as unique keys and are
not underlined
Another constraint on attributes specifies whether NULL
values are or are not permitted.
For example, if every STUDENT tuple must have a valid, non-
NULL value for the Name attribute, then Name of STUDENT is
constrained to be NOT NULL.
Relational Databases and Relational Database Schemas
model:
- referential integrity.
Integrity, Referential Integrity and Foreign Keys
Entity integrity constraint
existing tuples
Whenever these operations are applied, the integrity constraints
specified on the relational database schema should not be
violated.
The Insert Operation
provides a list of attribute values for a new tuple t that is to be
inserted into a relation R
can violate any of the four types of constraints
Domain constraints
- if an attribute value is given that does not appear in the
corresponding domain or is not of the appropriate data type
Key constraints
- if a key value in the new tuple t already exists in another tuple
in the relation r(R)
Entity integrity
- if any part of the primary key of the new tuple t is NULL
Referential integrity
- if the value of any foreign key in t refers to a tuple that does
not exist in the referenced relation
Operation:
Operation:
Operation:
Operation:
Delete the WORKS_ON tuple with Essn = ‘999887777’ and Pno =10.
Result: This deletion is acceptable and deletes exactly one tuple.
Operation:
i) domain ii) attribute iii) n-tuple iv) relation schema v) relation state
3. Discuss the various reasons that lead to the occurrence of NULL values
in
relations.