Relational Model
Relational Model
SYSTEMS
Data Model
► Entity is basic building block of the E-R data model. The term entity is
used in three different meanings or for three different terms and that are:
► Entity type
► Entity instance
► Entity set
The Entity
► Weak Entity Types: Similarly, if employee leaves the job and the
organization decides to delete the record of the employee then the record
of the vehicle will also be deleted since it cannot exist without being
linked to an instance of employee.
► Represented by:
Classification of Entity Types
► Following are some recommendations for naming entity types. But they are
just recommendations; practices considered good in general:
► Singular noun recommended.
► Organization specific names, like customer, client anything will work.
► Write in capitals.
► Abbreviations can be used, be consistent.
Attribute
► STORED ATTRIBUTE: Normally attributes are stored attributes, that is, their
values are stored and accessed as such from the database.
► DERIVED ATTRIBUTE: However, sometimes attributes’ values are not stored
as such, rather they are computed or derived based on some other value.
► For example, we may store the name, father name, address of employees, but age
can be computed from date of birth.
► Represented by:
► Doted line
Derived
ACTIVITY
EMPLOYEE Address
► A candidate key chosen by the database designer to act as key is the primary
key.
► The columns you choose to maintain uniqueness in a table.
► Here in Employee table you can choose either Employee ID or SSN columns,
Employee ID is preferable choice, as SSN is a secure value.
Super Key
► Super Key: A super key is a set of one or more attributes which taken
collectively, allow us to identify uniquely an entity instance in the entity
set.
► If you add any other column/attribute to a Primary Key then it become a
super key, like Employee ID + Full Name is a Super Key.
Super Key
► Once specific characteristic with super key is that, as per its definition any
combination of attributes with the key is a super key.
► For example, consider the entity type STUDENT with attributes registration
number, name, father name, address, phone, class, admission date. Now
which attribute can we use that can uniquely identify any instance of
STUDENT entity type.
► All the combinations “regNo, name”, “regNo, fName, address”, “name,
fName, regNo” and many others, all are super keys.
Alternate Keys
► The attributes on which we need to access the instances of an entity type that
may not necessarily return unique instance is called the secondary key (Using
non-key attributes) .
► For example, we want to see how many of our students belong to Multan, in that
case we will access those instances of the STUDENT entity type that contain
“Multan” in their address. In this case address will be called secondary key.
► Keep one thing in mind here, that a particular access on the value of a secondary
key MAY return a single instance, but that will be considered as chance or due
to that particular state of entity set.
Foreign Key