You are on page 1of 7

Single Valued attributes VS multi-valued attributes

- Single Valued attributes


An attribute that can keep only a single value for a single instance e.g. name,
class is called single valued attribute.

Name
Reg # Class

Student

- Multi-valued attribute
An attribute that can provide more than one values for an instance, is called multi-
valued attribute, e.g. Hobby.

Name
Reg # Class

Hobby
Hobby
Student

Repeating group
Two or more multi-valued attributes that have same logical association, forms a
repeating group.

Name
Reg # Class

Hobby
Hobby ID
Student
DBMS

Hobby
Hobby Repeating Group
Name

www.techtilldate.blogspot.com www.bscs15.blogspot.com
- Solution for repeating group
We take out the attribute of repeating group from entity class and make another related
entity class that contains these attributes.

Name Hobby name Hobby ID


Reg # Class

Student Have Hobby

Registers

Course

Reg # Reg #
DBMS

www.techtilldate.blogspot.com www.bscs15.blogspot.com
Candidate Key
An attribute that has the quality / characteristics to identify a unique instance of an
entity class is known as candidate key e.g. Reg #, NIC.

Reg # Name Class NIC #

Primary Key
A candidate key that has been selected as an identifier is known as primary key, e.g. Reg
no.

Name
Reg # Class

Student

Alternate Key
A candidate key other than primary key is known as alternate key e.g. NIC.
DBMS

www.techtilldate.blogspot.com www.bscs15.blogspot.com
Composite Primary Key
Sometimes there is a situation when there is no single that can identify a unique
instance. Therefore we consider two or more attributes for indentifying a unique
instance. These two or more attributes are called composite primary keys.

Name
Roll no Class

Student

Roll No Name Class

1 Ahmad BSCS

2 Ali BSCS

1 Sabir BSSE

Properties of primary Key


1. Can not have NULL value
2. Can not have duplicate value (should be unique)
3. Composite primary key should be avoided (can be used)
4. We should avoid the use of intelligent key* (a key that provided additional info),
normally we use the intelligent keys like Reg no, NIC, Car Reg no.
5. The value of primary key should not change through out the life of a data.

Employ no
ISB-6
LHR-9
KHI-4
Transferred to Lahore
So the name will change i.e. LHR-8
*So that’s why the use of intelligent key should be avoided.
DBMS

www.techtilldate.blogspot.com www.bscs15.blogspot.com
Existence dependency
It is a phenomenon in which instances of an entity class can not exist without the existence of
instances of another entity class.

M-Name Copy ID Media


M-ID M-Type

Movie Has a Movie Copy

Independent entity Class Dependent E.C


Strong E.C Weak E.C

Movie copy can not exist without the existence of some movie, so it is called as weak
entity class.

Identifying relationship
A relationship in which the weak entity class doesn’t have an identifier and we bring the
primary key of strong entity class in weak entity class to make it part of composite primary key,
such relationship is known as identifying relationship.

Copy ID
M-Name M-ID Media
M-ID M-Type

Has
Hasaa
Movie Movie Copy

M-ID Copy-ID Media


DBMS

1 1 CD

www.techtilldate.blogspot.com www.bscs15.blogspot.com
1 2 CD

1 3 DVD

2 1 Tape

Time Dependant data


Sometime data is dependent upon time so we use time stamp (an attribute that keeps date or
time or both) to keep track of data with respect to date and time.

P-Name P-Price
P-ID P-Price

Time Stamp

Effective
Effectivedate
Product date

Requirement
User wants to keep all prices of a product along with the date when it was purchased.

Price
P-Name P-ID Date
P-ID

Has a
Product Product

P1-TFT 17”
Price Date

14000 3-2-2009
DBMS

www.techtilldate.blogspot.com www.bscs15.blogspot.com
12500 28-2-09

12000 1-3-09

12050 15-3-09
DBMS

www.techtilldate.blogspot.com www.bscs15.blogspot.com

You might also like