We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
anenpe-— — ~
Example: ® “lowing diagram we have two entities g;
r
ne ionship. The relationship between Studer" any
many to one as a college can have many students howeye’ (
cannot study in multiple colleges at the same time. Stude,t ®
attributes such as Stu_Id, Stu_Name & Stu_Addr and Cotte '
putes such as Col_ID & Col_Name. Re
and t.
a
attri iy.
pe
) ¥
\°
\ 7
t t
'
Figure 5.5: A sample E-R Diagram
Following are the geometric shapes and their meaning in an B-R
Diagram.
Rectangle: Represents Entity sets.
Ellipses: Attributes
Diamonds: Relationship Set
Lines: They link attributes to Entity Sets and Entity sets to 1
Relationship Set
Double Ellipses: Multivalued Attributes
Dashed Ellipses: Derived Attributes
Double Rectangles: Weak Entity Sets
Double Lines: Total participation of an entity in a relationship#
Components of an ER Diagram
ER Model
Entity Attribute lonship
Key ‘One to One
‘Weok Composite
Entity One to Mony
Multwolued Many to One
Derived Many to Mony
Figure 5.6: Components of E-R Diagramoh, ——————__.
qn id the above diagram, an ER diagram has three main
0
ss" nents:
Fnpone” entity
“attribute —
iii. Relationship
an object or component of data. An entity is
nted aS rectangle in an ER diagram.
represe” te: In the following ER diagram we have two entities Student
0 entities have many to one relationship as.
for College and these tw
tudy in a single college. We will read more about
an’, students S' lle
ee tionships later, for now focus on entities.
relat
tit F
1 ara tity is
»_ college.
9, Attribute
‘An attribute describes the property of an entity. An attribute is
represented as Oval in an ER diagram. There are four types of attributes:
i. Key attribute
Composite attribute
Multivalued attribute
iv. Derived attribute
Key attribute:
A key attribute can uniquely identify an entity from an entity set.
For example, student roll number can uniquely identify a student
from a set of students. Key attribute is represented by oval same as
: other attributes however the text of key attribute is underlined.VI
il er : . 1
Composite attribute at is a combination of other g, ~\
ribu 7 axe > @:
An attri waite attribute. For example, In student ety
known as ema js a composite attribute as an 4 tig
nt addres ttributes such as pin code, state, Count, Tea
ty |
le)
stud f other al
composed 0}
Address Is 0 composite attribute
Multivalued attribute: ;
An attribute that can hold multiple values is known
multivalued attribute. It is represented with double ovals in ang
Diagram. For example - A person can have more than one Pho
numbers so the phone number attribute is multivalued.
Derived attribute:
A derived attribute is one whose value is dynamic and derived froy
another attribute. It is represented by dashed oval in an B
Diagram. For example - Person age is a derived attribute asi
changes over time and can be derived from another attribute (Dat
of birth).
Figure 5.7: E-R di i it
3. Relat ionship diagram with Entity and Attributes
A relationship is re am, it
. ond shape in ER diagram |
: s ip amo iti
elation ships: ng entities, There are four types
J One to OneMS 215
Many to One
Many to Many
iv.
one to One Relationship
When a single instance of an entity is a
single instance of another entity then it is cae
i ip. For example, a person has
relationship. — Peoae as only one pa
passport is given to one person. “ Passport and a
ed with a
done to one
“Person —!_ at The? i> Passport
One to Many Relationship
When a single instance of an entity is associated with more
than one instances of another entity then it is called one to many
relationship. For example ~ a customer can place many orders but
aorder cannot be placed by many customers.
pcs. > Order
Many to One Relationship
When more than one instances of an entity is associated with a
single instance of another entity then it is called many to one
relationship. For example - many students can study in a single
college but a student cannot study in many colleges at the same
time.
many to Many Relationship
ees than one instances of an entity is associated with mor
telationshis stances of another entity then it is called many to mar
Aproject on, wor example, a can be assigned to many projects an
ect can be assigned to many students.
® -
Braden TM co hasan M preiect
meCo7
- inoroactiOn to a)
nal model in DBMs, .
gancaT ”
sriefly describe Relatio!
a9
in DBMS
nal mod eae the data and relationships are ,,
Each table is a group Pe
COly,
gelation i
in relation’ -related tables. ta
in represents attribute of an entity a
cr
Model:
Je is created with three column,
S ay
My
lationship
t tab!
mple ¥
s Phe following Studen'
records.
able: Student
Stu Id | Stu_Name Stu Age >
am Majid 7
[123 [Umair 22
169 [Mohsin 84
| 234 [Iqbal 26
Table: Course
[ Stu_ld Course_Id |Course_Name
it col [Science
z 2 C02 [DBMs
[169 = Pars
c39 |Computer Networks
Here Stu_Id, St
id, Stu_Name
Sula, Course_Id & Comes ee are attributes of table Studet
v > an i
lues are the records a of ae came
as tuples).
; Briefl i
Q.10 y describe Relational Database Managemet!
System (RDB
MS) and its mai
RDBMS Concepts its main components.
. 7
iou BEN » stores
1
A
A
Record or Tuple
Field or Column name or Attribute
Domain
Instance
Schema
Keys
re invroauceens we one
= CH -
7 5S-DEMS a7
ii.
ble .
4,78 table is a collection of data represented in rows and columns.
ie has a name in database. For example, the following table
.s the information of students in database.
gable: STUDENT —__—— (ade \eandant ann
gadent 14 [Student_Name _[Student_Addr [Student _age |
mt [Majia [Multan jaz \
i [Umair Faisalabad pe |
i __ Saleem [Lahore a4 |
ioe [Ahsan ~ [Islamabad ps "|
2,Record or Tuple
Each row of a table is known as record. It is also known as tuple.
for example, the following row is a record that we have taken from the
is
above table.
{oa [Umair Faisalabad pe |
3. Field or Column name or Attribute
The above table “STUDENT” has four fields (or attributes):
4 dent_Id, Student_Name, Student_Addr & Student_Age.
} Domain
eran ‘ domain is a set of permitted values for an attribute in table. Fo!
Pen I; a domain of month-of-year can accept January
mossibie December as values, a domain of dates can accept al
table, Valid dates etc. We specify domain of attribute while creating
An atte
Ome at cannot accept values that are outside of their domains. Fc
Somain ‘so tae above table “STUDENT”, the Student_Id field has integ
“tuple, Studes field cannot accept values that are not integers f
lent_Id cannot has values like, “First”, 10.11 etc.what are the Keys used in RDBMs>
types? ‘
BMS
Keys ne an important role in relat
ey ving unique rows from table. It als
i \
Ss.
types of keys in DBMS
primary Key - A primary is a column or se of |
that uniquely identifies tuples (rows) in that tabje Us nay
super Key - A super key is a set of one of
q. 11
Onal dat,
a]
‘0 establishes SS it,
Tela 8, Y
tating }
Pa,
(attributes) to uniquely identify rows in a table, More Ok
Candidate Key - A super key with no ,
known as candidate key
Alternate Key - Out of all candidate keys, only one
as primary key, remaining keys are known mn en vy
secondary keys. ema,
Composite Key - A key that consists of more than one att
uniquely identify rows (also known as records & tuples) inet
is called composite key. 4
Foreign Key - Foreign keys are the columns of a table that po
to the primary key of another table. They act as a crossctece
between tables.
Q.12 Write anote on Query Languages in DBMS.
redundant attr .
ye
Query Language
In simple words, a Language which is used ‘to store and ret
data from database is known as query language. For esr
Structured Query Language (SQL).
There are two types of query language:
1 Procedural Query language
i. Non-procedural query language
Figure 5.8: Types of Quers 1a...