Chapter 3
Chapter 3
1
Building Blocks(1)
Entities: Real world physical or logical object.
Attributes: Properties used to describe each Entity
or real world object.
Relationship: The association between the real
world objects (i.e. Entities.)
Constraints: Rules that should be obeyed or
followed while manipulating the data.
2
Building Blocks(2)
The name given to an entity should always be a singular noun
descriptive of each item to be stored in it.
Attributes - The items of information which characterize and
describe these entities
Attributes are pieces of information about entities
4
Cont…
Stored vs. Derived Attributes
Stored : not possible to derive or compute. E.g. Name, Address
Derived: The value may be derived (computed) from the values of
other attributes. Ex. Age (current year- year of birth), GPA (grade
point-credit hours)
Null Values: NULL applies to attributes which are not applicable
or which do not have values.
Value of a key attribute can not be null.
5
Degree of a Relationship
Degree of a relationship is the number of entities
participating in relationship.
6
Degree of a Relationship
Binary relationships- records of two entities are associated in a relationship.
9
Relational Integrity
Domain integrity: No value of the attribute should be beyond
the allowable limits.
Entity integrity: In a base relation, no attribute of a Primary
Key can assume a value of NULL.
Referential integrity: If a Foreign Key exists in a relation,
either the Foreign Key value must match a Candidate Key value
in its home relation or the Foreign Key value must be NULL.
Enterprise integrity: Additional rules specified by the users or
database administrators of a database are incorporated. 10
Types of Keys- Super key
A set of one or more attributes that in group (collectively) can
within a relation.
Eg. Employee(EmpID, EmployeeName, SSN, DeptID, DOB)
Uniqueness
Irreducibility
13
Types of Keys – Alternative
key
Candidate column other than the Primary column,
like if EmployeeID is set for a PK then SSN would be
the Alternate key.
Employee(EmpID, EmpName, SSN, DeptID, DOB}=
SSN
14
Types of Keys - Composite key
Composite key: A candidate key that consists of two or
more attributes.
If a table do have a single column that qualifies for a
Candidate key, then you have to select 2 or more columns to
make a row unique.
Like if there is no EmployeeID or SSN columns, then you can
16
Types of Keys - Primary key
(1)
Primary key: the candidate key that is selected to identify
tuples uniquely within the relation. Can not null value.
It is a candidate key that is chosen by the database designer
to identify entities with in an entity set.
at row level
17
Types of Keys - Primary key
(2)
No two rows can have the same primary key value
Every row must have a primary key value
The primary key field cannot be null
Value in a primary key column can never be
modified or updated, if any foreign key refers to that
primary key.
18
Types of Keys – Foreign Key
Foreign key: an attribute, or set of attributes, within one
relation that matches the candidate key of some relation.
A foreign key is a link between different relations to create
relationship or view.
19
Types of Keys – Unique Key
Unique key is same as primary with the difference
being the existence of null.
Unique key field allows one value as NULL value.
20
Relational Views (1)
Relations are perceived as a table from the users’ perspective.
There are two kinds of relation in relational database.
Base (Named) and
View (Unnamed) Relations.
The basic difference is on how the relation is created, used and
updated:
Base Relation: A named relation corresponding to an entity in
the conceptual schema, whose tuples are physically stored in
the database. 21
Relational Views (2)
View (Unnamed Relation): A View is the dynamic result of
22
Schema
Database Schema (Intension): specifies name of relation and
the collection of the attributes (specifically the Name of
attributes).
Refer to a description of database (or intention)
Specified during database design
Should not be changed unless during maintenance
update an item.
Valid state: the state that satisfies the structure and
25