Professional Documents
Culture Documents
to foreign key
t:1 or 1:N elationshiptype
M:N relationship type a relation and two foreign keys
cname
an attribute (or fields) Phone no.
Simpleattribute cid
S. Value sets domain
Key attribute primary key City
CUSTOMER
This is how an ER-model is converted directly to a Relational model. So, an ER-
diagram acts as a blueprint of the database. It allows a designer to communicate more Fig. 1.30
precisely. Solution. Since CUSTOMER is entity with composite attribute-cname. So, the rule
an
These conversions can also be done using CASE tools. followed isThe composite attributes are flattened out by creating a separate attribute
for each component attribute." So, in our table, we will have the following flattened
1.7 sOME SOLVED EXAMPLES attributes
We are in a position to solve some examples now. CUSTOMER (Cid, fname, mname, Iname, phone no, city)
Example 1. Consider the following suppliers-parts-projects database: Thus, we can say that a multi-valued attribute, M, of an entity, E, is represented by
to
a separate table EM. And that this table, EM, will have the attributes corresponding
SISt, SNAME, STATUS, CITY the primary key of E and an attribute corresponding to multi-valued attribute, M.
PP#, PNAME, COLOR, WEIGHT, CITY shown
JJ#, JNAME, CITY Example 3. Consider an ER diagram now that has a weakentity set-Paymentas
below:
SPJ(S, Pt, J#, QT)
Pay date Pay
emount
Where S: Infomation of Pay no.
suppliers Loan-no. Amount
Parts
J Projects
SPJ Supplied quantity LOAN
Loan
pay
PAYMENT
Draw it's ER-diagram? WEAK
STRONG
Solution. Using our rules, listed earlier we
get the following ER-diagrams: Fig. 1.31
DATABASE MANAGEMENT SYSTEMS
46 INTRODUCTION TO DATABASE MANAGEMENT SYSTEMSs 47
How will you transform (convert) this table into a Relation, KR
from the Example 7. An information system is to be designed for keeping the records of
primary key or discriminator
Solution. We create a new relation, R with oneattributes Universe cup cricket tournament. In all, there are teams from 10 countries participating
other of the STRONG entity-LOAN
WEAK entity-PAYMENT and all remaining in the toumament. Each country sends 15 players and 4 other members. For players,
That is, the runs he scores and the number of wickets taken (so far) are to be recorded. For
R(loan -no pay-no pay-date, pay-amt) set into non-players, the role (manager, coach etc.) and the number of years of experience in
Example 4. How will you convert a M: N (many-to-many) relationship a
that capacity are to be recorded. There are matches scheduled amongst the teams on
relation, R? several grounds on fixed dates. Each ground has a fixed seating capacity and a size.
Solution. The rule is "Create a table with columns for the primary keys of the two
For 38 matches, 11 referees have been assigned duties. Every match will have 3 referees
set."
participating entity sets and any descriptive attributes of the relationship working for it. The performance of every player in every match is to be recorded ina
and (E F, G) and hat
For example, Let R and R, be 2 relations. IfR, (A, B, C, D)a newR,relation R with the
terms of the runs he scored and the wickets he took. Draw an E-R model of the system.
R and R have M: N relationship type then we need to create Design table layouts fom E-R model.
attributes, R(A, E). (Pune University, BE (CSEIT)-3 yr, Dec. 98)
Example 5. Horw can you comoert two entities into a table which has1:M elationship hype? Solution.
Solution. 1: M (one-to-many) and M: 1 (many-to-one) relationship sets that have
total participation on the many side can be represented by adding an extra attribute to
Ref name
the many side, containing the primary key of the one side.
For example, say R and R are the two entities with M: 1 relationship type ie, Refid Country
field-1 Refree
fhield-1 field-2 held-2
R rel-type
K field-3
Country
Match
refree
Seating Day Date Date Day
capacity Team id
Fig. 1.32
Match Match Team
Here, instead of creating a table for 'rel-type Ground Match schedule
field of R, to R. (relationship), we can add an attribute/ ground
Example 6. A chemical or set of chemicals give rise to another chemical or set of Match id (P_countryD name) (P name
chemicals, when reacts under no condition or a set of conditions. P.id
sodium react to give Sodium Hydroxide Like, water and Mruns Match
Whereas CH, and Clh form chloromethaneand Hydrogen and no condition is required. detail Player Non-player
reactions possible and each reaction has towhen exposed to light. There are numerous
be given a reaction
and condition has to be given a code. Draw its number. Each chemical M_wickets P matches Team i d NP
Solution ER-diagram. Crunse wickets
COuntry
State
Chemcode Name Team i d Date
01 1001 100 2
Mid 001
001 01 2001 57 0
001
002
Example 8. Assume you are requirements of a wholesale
to compose database
from different manufacturers (brands).
2. Ground Table: dealer for audio, video consumerequipment
credit to old
Customers are the various retail outlets (retailers). Wholeseller extends
You have to
8id Country Gr_city Size Customer and special discounts are offered to new customers (retailers).
Capacity with the scope restricted to
India generate an E-R model for the above DBMS application
101
Bombay 1000 20,000 details (queries on) of customers (retailers), products stocked
and their price discounts
201 Australia Melbourne 2000 15,000 (Pune University BE (CSETT) Dec. 97)
and credits offered etc.
3. Referee Table: Solution. Description of entities:
1. Consumer-equipment with attributes lequip id)
Refid Refname Refcountry 2. Audio-equipment with attributes la id, equip_id, brand)
011 XYZ 3. Video equipment with attribute {V_id, equip_id, brand)
021 PQR
England 4. Wholesale-dealer with attributes (dealer_id
India
4. Player Relation: 5. Customer with attributes (cid, cnamel
6. New with attributes (c_id, c_name, discount
Team id Player id Ply_age Ply_name Ply runs P_wick Ply match|
7. Old with attributes (c id, c name, credit}
1001 01 24 Sachin 8000 75 250
Description of relationships:
2001 01 34 Mark 6000
Cons-whole with attributes lequip_id, dealer)
220
Equip-cost with attributes lequip id, dealer, cust id, cust _name)
DATABASE MANAGEM
TSTEMs
MINTRODUCTION TO DATABASE MANAGEMENT SYSTEMS
50 51
(Dealer
id Name
Equip id City
A AD M Mnam
Wholesale
dealer Act
Consumer Cons_whole address Actor Movie
equipment add movie
movie
Street
Equip_cost Dir
(Add_id Director
Audio Video Cust id address
equip equip
Customer Street City Name
Name
Brand Aid Vid Brand Fig. 1.36. E-R Diagram
that has a set of
Discount ISA Credit Example 10. Construct an E-R diagram for a car-insurance company
customers, each of whom owns one o r more cars. Each car
has associated with it zero
M toany number of recorded accidents. (Pune Universitv BE (CSEAT; 3 yr.,
Dec. 2002)
New Old Solution.
number of repair shops who reap 80% of repair charges. Each of videobec's store is ra
by a manager and an assistant manager who are full-time employees. In addition, ead camera
storehires its own part-time help who are paid on an hourly basis. The membernhi
priviledge is extended to customers for a period of 1 year and is renewable unless Str
Employee
member is habitually tardy in retuming items borrowed. A member is allowed to re omp
upto 12 movies, 6 video games, 1 vCR and 1 video camera simultaneously. Movies an
8ames can be retumed to any store but VCR and video cameras have to be returmed Equipments SIore Catalogue
the store from which they were boowed. Members have access to the on-line catalogu
of titles and may reserve titles. A reserved title has to be
which the reservation is automatically cancelled. Itenm are
picked before 6 p.m, afte
VB
items are to be retumed before noon.
charged per day and borrowe store
Any late retum bears a charge of 1 additional day
A discount of 20% is awarded on week days for all items
rented and a total discoun Movie Games
of 33% is also given on movie
rentals on week days, when more than 3 titles a
borrowed at a time. Movies are held by Videobec in both VHS and
Beta format. The
Videcbel
catalogue of movies contains title of movie, producer, director, 2 leading actors
of movies, number of cassettes available and categone
charge per
contains the name of the game, game system and day.
The video games catalogat VB
multiple copies of same title charger per day. Videobec came ReP
copies of each title.A store that and
a store
would have been assigned any number
to has more copies will retum these at the end of each o
Videobec's head office which redistnbutes them to wee Repair
diagram. appropriate stores. Draw E shop
Solution. Description of Entities: Mem
Mem Member
1. Videobec is an
entity with attnbutes name, address, quip
cat
Example 13. An insurance agent sells insurance policies to clients. Policies can b Sta
of different types such as vehícle insurance, life
insurance, accident insurance e t
The agent collects monthly premiums on the
policies in the form of cheques
local banks. Appropriate attributes must be assumed for various entities
such as agens
vehicles, policy. Dayis
Draw an E-R model for above
system. Your E-R model should take advantage d
extended E-R notation where relevant.
Fine Studer
(Pune University BE (CSEIT); 3
Solution
yr., June 2000, 12 Marks Day ret
Name ISA
St ld
Agent
Bank Policies Borrowe
name
Fig. E-R Diagram for Ex. 14
medical record database system, given the
se Example 15.
following data
t is required to set-up
Patient
Physician
Delivers
(Name of
(Temp Date
Sender
Every receiver has a name and an address. Every professor teaches exactly one course and each course must be taught bby
one professor.
Every postman has a
designated area where he delivers letters teach certain jointly, but it is
Now suppose that team of professors can courses
The consists ofa set of streets under team can teach the course. Model this
are
the jurisdiction of the post office. possible that no one professor in a
sets and relationship sets if necessary.
Every street consists of a set of situation, introducing additional entity
buildings. Solution.
Every building has a number and may be a name. It Recent
one family. may be housing more tna 4 Professo offering
Course
to the sender.
Draw the E-R Diagram
() Professor Course
Teach
Professor
(5) Professor
Database with Courses and Professors Information
Fig. 1.45 University
DATABASE MANAGEMENT SYST
Example
The
21. Design a generalization-specialization hierarchy for motor-vehicle a
Students sales. company sells motorcycles, passenger cars, vans and buses. Justify the
placement of attributes at each level of hierarchy.
Fig. 146. E-R Diagram of
University Database (Pune University BE (CSE/TT; 3 yr, May 2003)
Example 19. Draw an E-R
diagram for a relational database Solution.
current term enrollment at that
Pune University with
instructors, 4000 courses and 30,000 students.
represents
following assertions. There are 2
Motor-Vehice
An instructor may teach none, one or more
courses). courses in a
An instructor must direct the given term (aver ISA
A course may have
research of at least ney
none, one or wo one student (average 2 stude Buses
A course may exist
even if no
student has
prerequisite
courses.
All courses are
taught by only one currently enrolled for that Passanger
The average enrollment in E-K
a
instructor Model cars Vans Model
A student must select at course is 30
least one
course per term. students.
(Pune Model Model
University BE (CSED; 3 20
yr, May Fig. 1.49. E-R Diagram of Motor Vehicle
DATABASE MANAGEMENT SYSTE
60 INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS 61
system:
ample 22. Draw for the following
the EER (ER) diagram Solution.
interactive, dynamic, secure
The project Nexus data mart' aims at providing an of
data warehouse of
an
Punj
& handling the (F-name M-name Lname F-name (M-name name (cvv No.
user
friendly'platform for reating, managing
part of the
National bank with the intend of reducing
workload on the
Databas
dN
Administrator and concurrently maintaining security at all ieves Name Type D.O NameCard NoType 0.0E
Nexus Data Mart is an efficient data handling system for establishing monitorin
and automating the data warehouse related tasks of companies. The software componen
of the system are developed using the shell programming features of UNIX (operatin ATM Data
and the hardware components adhere to the client-sever architecture.
System)
A farewell has been established to enhanced the security of the whole system. Th Credit Card Data
tasks performed by the system include extraction &e transformation of data available in th
or redundant informatia
form of raw data sheets, filtering of data to reduce
the quantity
within the system, entertaining requests of communication from the end-user an
F-name M-name name
establishing contact through a Mail Server and implementing an X-server to increase th
ease of operability of the system.
Name
At any state of the implementation of the ETL (Extraction-Transformation-Loading Acc. No Cust1D Email 1D
processes, sensitive data belonging to the organisation shal remain abstracted from t -Data
End-User thereby ensuring a high level of
security and sophistication for a naive usert
get hold of the functionality of the system.
Customer
The system's high efficiency Name Privilege
must be credited to the
power offered
by The Shell in FULL U-D
UND programming environment. The
scripts are concise yet extremely powerful, easy to
maintain and modify as per needs of the Sendmail
organisation being served. The main advantag
of programming within the UNIX environment is
the security that is offered
by the operating Processes Administrator
system at various levels. UNIX has three inherent provisions for
is provided by assigning protecting data. The firs
password and login names to authorised users At the file
level, high level of security is implemented only.
that are assigned to users by the
through read, write and execute permissions Server Sendmail
system administrator.
facility that allows us to export data in an unreadable Lastly, there is file encryption
format.
Nexus Data Mart is thus a robust Mail Server
system which is easy to maintain Bank
portable to all operating system that belong to the Unix and modify. Its Provides
Linus, AD, Fedora, CenOS, and Ubuntu etc. The
family such as Solaris, Red Hal
considerably by increasing its flexibility through system's's capabilities can be enhanced B-Address
Drogramming languages and increasing the rangetranslating the code into more than o B-Name B-Code
of formats in which data sheets can
fed into it. Draw its Enhanced ER
diagran
Protoco Mail Client Responder Type
Automatis
Fig. 1.50.