DB - Lec - 5 and 6
DB - Lec - 5 and 6
Choose DBMS
Implement System
Test System
Operational Maintenance
Slide 1-4
Using High-Level Conceptual Data
Models for Database Design
COMPANY
– Employees, departments, and projects
– Company is organized into departments
– Department controls a number of projects
– Employee: store each employee’s name, Social
Security number, address, salary, sex (gender),
and birth date
– Keep track of the dependents of each employee
Entity Type
A name /label assigned to objects/items that
exists in real world and that have similar
properties
EMPPLOYEE DEPENDENTS
BOOK BOOKCOPY
Naming convention for entity type
Singular name recommended
Simple
Composite
Multi-valued
Derived
Symbols for Attributes
Example of derived Attributes
Example of composite
Attributes
Example
EMPLOYEE address
The combination of “SSN” and “Name” is a super key of the following entity set customer.
Because:
The value of attributes “SSN” and “Name”, such as 558-36-1234 and Susan, can
uniquely identify that particular customer in customer entity set, which is the pool of all
customers.
Properties of
Candidate Key…..
While most entity sets have only one candidate key,
some entity sets could have more than one candidate
key.
Candidate key could have more than one attributes.
In building a database in a database software, the
software will only allow to use one candidate key to be
the unique identifier of an entity for an entity set.
Candidate key
Example:
(SSN, Name) is NOT a candidate key, because taking out
“name” still leaves “SSN” which can uniquely identify an entity.
“SSN” is a candidate key of customer.
Example: Both “SSN” and “License #” are candidate keys of
Driver entity set.
Customer-street
SSN
Customer-city
Customer-name
customer
Overall, Super Key is the broadest unique identifier;
Candidate Key is a subset of Super Key; and
Primary Key is a subset of Candidate Key.
In practice, we would first look for Super Keys. Then
we look for Candidate Keys based on experience
and common sense.
If there is only one Candidate Key, it naturally will be
designated as the Primary Key.
If we find more than one Candidate Key, then we
can designate any one of them as Primary Key.
Primary Key
Properties Of Primary
Keys....
To qualify as a primary key for an entity, an attribute must have the
following properties:
It must have a non-null value for each instance of the entity
The value must be unique for each instance of an entity
The values must not change or become null during the life of each
entity instance
Primary and Foreign keys are the most basic
components on which relational theory is based.
Each entity must have a attribute or attributes, the
primary key, whose values uniquely identify each
instance of the entity.
Every child entity must have an attribute, the foreign
key, that completes the association with the parent
entity.
Foreign key
A Foreign key is an attribute that completes a
relationship by identifying the parent entity.
Foreign keys provide a method for
maintaining integrity in the data (called
referential integrity) and for navigating
between different instances of an entity.
Every relationship in the model must be
supported by a foreign key.
Foreign Key
Properties Of
Foreign Key….
Every dependent and category (subtype) entity in the model
must have a foreign key for each relationship in which it
participates.
Foreign keys are formed in dependent and subtype entities by
migrating the entire primary key from the parent or generic
entity. If the primary key is composite, it may not be split.
Composite Key
When a primary key is created from a combination
of 2 or more columns, the primary key is called a
composite key.
Each column may not be unique by itself within
the database table but when combined with the
other column(s) in the composite key, the
combination is unique.
Keys, and Value Sets
OFFERING
ProgCode CourseCode MarksAlloc CrHrs
MCS DS 100 3
MCS DBS 100 3
MBA DBS 100 3
BCS NW 100 3
Composite Key Example