Extra Dbms
Extra Dbms
App i"ation Pro#ra$$er%& Application Programmers are responsible for writing application programs that use the database. These programs could be written in General Purpose Programming languages such as Visual Basic, Developer, , !"#T#A$, "B"% etc. to manipulate the database. These application programs operate on the data to perform various operations such as retaining information, creating new information, deleting or changing e&isting information.
ADD in "hapter 2 a!ter 2.5.' e(ten)e) !eat*re% o! ERD an) +e!ore 2., o-ra %tr*"t*re E) Di!!eren"e +et/een %pe"ia i0ation an) #enera i0ation 1pe"ia i0ation Genera i0ation
%.%te$
*peciali+ation means creating Generali+ation is the process of new subclasses from an e&isting e&tracting shared characteristics class. from two or more classes, and combining them into a generali+ed super class.
,(
Position of .n speciali+ation, some higher .n generali+ation, each higher level entitlevel entities ma- not belong to entit- must also be a lower level lower-level entit- sets at all. entit-. *tructure 1&le *peciali+ation is developed top- Generali+ation is developed bottomdown up. .n speciali+ation, an emplo-ee entit- would be bro2en down into engineer, manager, and secretarentities. 3sing generali+ation, an anal-st first develops engineer, manager, and secretar- entities and then creates the emplo-ee entit-.
/( 0(
[a)) to "hapter 2 in 2.5 2 C) notation o! entit. re ation%hip )ia#ra$ 32) at en) o! /ea4 entit. ] Note& a)) on . i! ne"e%%ar. a%4 !or 5 $ 6*e 7ea4 Entit. &
The 1ntit- that has no an- 2e- attribute of its own is 2nown as 4ea2 entit-. A wea2 entitalwa-s has a total participation constraint with respect to its identif-ing relationship, because a wea2 entit- cannot be identified without an- owner entit-. !or e&le a passport entit- cannot be e&it without a person entit- or a mar2sheet cannot be e&it without student entit-. A wea2 entit- generall- has a partial 2e-, which is a set of attributes that can uni5uel- identifwea2 entities that are related to same owner cit-. entitountr- and ever- value of onsider the entitit- that is dependent to hennai are it-6$ame e.g., Delhi, )umbai, 7ol2ata and
dependent on .ndia similarl- 7arachi and .slamabad are dependent on Pa2istan and if Pa2istan is deleted from the ountr- table it means both 7arachi and .slamabad are also deleted from ountr- entit- is 2nown as .dentif-ing entit- or Parent entit- and it- Table. .n this e&le the
it- entit- is 2nown as *ubordinate entit- hild entit-. E(a$p e& A named double rectangular bo& in 1# Diagram represents the wea2 entities
[ADD TO C8APTER 2 IN e(a$p e% o! ERD 9 a%t point)] 8( An .nsurance Agent sells insurance policies to clients. Policies can be of different t-pes such as Vehicle .nsurance, %ife .nsurance, and Accident .nsurance etc. The agent collects monthl- premiums on the policies in the form of che5ues of local ban2s. Database should provide the following details to the user9 a) .dentif- all entities. +) .dentif- all relations ") 1-# Diagram : ; mar2 < 1o *tion& 1ntities are as below9 a) Agent +) Policies
")
lient
)) )onthl- premium Re ation%hip& a) The agent table is related with policies table as a one to man- relationship +) The insurance table is related with client table as man- to one relationship. ") The agent table is related with policies table as one to man- relationship
Amoun t
Monthly premium
on
Policies No
Clien t
ClientN o ClientNa me
=( A compan- has several departments. 1ach department has a supervisor and at least one emplo-ee. 1mplo-ees must be assigned to at least one, but possibl- more departments.:; mar2< a) +) ") 1o *tion& Entitie%& C_addre a) ompanss C_na me +) Department ") *upervisor Company )) 1mplo-ee Re ation%hip& M has 1 !epartmen t 1 .dentif- all entities .dentif- all relation Draw 1-# Diagram
!_no !_nam e
a) The compan- table ma- have one to man- relationship has with department table +) The Department table ma- have one to one relationship with *upervisor table. ") The Department table ma- have one to man- relationship with emplo-ee tables. )) The emplo-ee Table ma- have one to one relationship with department table. ha e M Employee 1 E_no E_nam
S_nam e
about ,?,??? consumers. The consumers are divided into three categories. Agricultural, ommercial, Domestic for whom different rates are charged. The bills are made according to the meter readings which are paid b- the consumers. a) .dentif- all entities. +) .dentif- all relations. ") Draw 1#D. 1o *tion& Entitie% are& a) Distributor +) onsumer
") Bill Re ation%hip & a) Table distributor ma- have one to man- relationship with consumer table
+) Table consumer ma- have one to man- relationship with table bill Entit. Re ation%hip Dia#ra$& !_no
!_na me
C_n o
C_nam e
ISA
Agricultur al
Commercial
!omesti c
;( .n a nurser-, the plants are sold to the customers. These plants are flowering and nonflowering onl-. $utrients are given to the plant with some 5uantit-. $utrients includes pesticides, watering and manure 9 a) .dentif- all entities. +) .dentif- all relations. ") Draw 1#D 1o *tion& Entitie%&
)) $utrients Re ation%hip a) The table nurser- ma- have one to man- with relationship plant table +) The customer table ma- have one to man- with relationships plant table. ") The nutrient table ma- have man- to one relationship with plant table. Entit. re ation%hip Dia#ra$&
$6name
$urser-
ontai nss
Plant
Given to
*old to
$6no
Chater3: [ADD TO C8A.: "hapter) 5) in :.5.2 in e(a$p e% o! re ationa a #e+ra operation%] 9At the en) o!
onsider relational database 9 )achine @mno, mname, mt-pe, mcost( Part @pno, pname, pdesc, mno( )achine and Part are related with one-man- relationship. a) %ist all machines having cost greater than 8???. ;*er.&
A@mname( @B mcostC8???@)achine((
Fmname@B
pnameGEwheelE
@parts((
A@pname( @B mnameGHtelevisonH@)achine((
)) Displa- the machine names whose cost is between 8?,??? to >?,???. ;*er.& <@mname( @B
8????ImcostC>?,???@)achine((
5)
onsider the following #elational Database 9 Department @dept6no, dept6name, location( 1mplo-ee @e6no, ename, addr, salar-, designation, dept6no( Department and 1mplo-ee are related with one to man- relationships.
Aename@B designationGH)anagerH@1mplo-ee((
+) %ist all emplo-ees whose salar- is greater than '?,??? and less than ,8,???. ;*er.&
Aename@B '????Csalar-I,8???@1mplo-ee((
it-.
Aeno,ename,addr,salar-,designation@Bdept6nameGHAccountH3locationGHPuneH@1mplo-ee((
)) Displa- Department $ame and 1mplo-ee $ame wor2ing in D*alesE or D.nventor-E ;*er.&
Adept6name,ename@Bdept6nameGEsalesE3dept6nameGEinventor-E@Department((
Chapter 5 [ADD in C8.5 a!ter 5.:.: t.pe% o! !*n"tiona )epen)en". an) +e!ore 5.5 nor$a !or$]
5.:.5
') Re)*"tion o! Re)*n)ant Data & Data redundanc- is reduced, which simplifies data structures and conserves dis2 space. Because duplicate data is minimi+ed, the possibilit- of inconsistent data is greatl- reduced. 2) Data Con%i%ten". & Data inconsistenc- will become a problem e.g. information is duplicated in each s-stem and ma- be updated in most s-stems .Data consistenc- $ean% that each user sees a consistent view of the data, including visible changes made b- the userJs own transactions and transactions of other users. :) F e(i+ e Data+a%e De%i#n& To ma2e database structure fle&ible i.e. it should be possible to add new data values and rows without reorgani+ing the database structure. *earching, sorting, and creating inde&es is faster, since tables are narrower, and more rows fit on a data page. 5) Data+a%e 1e"*rit.& Data securit- is the protection of the database from unauthori+ed users. "nl- the authori+ed persons are allowed to access the database. )ost of the users are allowed to access a part of database i.e., the data that is related to them or related to their department. 5) Re!erentia Inte#rit.& #eferential integrit- simpl- means that the values of one column in a table depend on the values of a column in another table. !or instance, for a customer to have a record in the "#D1#*6TB% table there must first be a record for that customer in the 3*T"KA1#6TB% table. lntegritconstraints can also control values b- restricting a range of values for a column. The integritconstraint should be created at the tableEs creation. #eferential integrit- is t-picall- controlled through the use of primar- and foreign 2e-s.