You are on page 1of 21
EER = Enhohced Entity Relationship Hode Gub- Classes and Super - Classes €g:- Employee ~ Serneare Engineer, Technic Manager, etc: Each of these SubgrouPing 15 a subset of Employee entities Super class - Employee sub class - Secretary These also called Is -A Retattonship egi- Secretary pa- AP Employee )| The sub class member iS +he game fentl ty ina distinct specific role 3 An entity cannot exis t in the database merely by beign a member of Sub class, \t also -be must be a member of the supet class 3) A super Class member can be oP tionally Included a3 a member of any number ot L Subclass es Attribute Bnberitance in Super ctass / Sub “Claoe Relation shi An entity that {fs member Of a subclass inherits all the attr|/butes of the entity as a MEME mmber OL dhe Super class bo :- Secretary inherias the asribute NAMe, ssn... from &m ployee Every secretary endity win for the Inherited attributes have values | oY Specialization The process g¢ defining % set of subcloss of a super - class. The set of sub - classes is based upon some characteristic of the entitles In the super - class €g+- % Secretory, Engineer, Technician % _ sob ae | L_ salaried. employee , Hourly - Employee - method of poy. d > «Attributes of a. gub-classes iS called | Specific or local attri butes * The Sub class. can also participat Ip Specific relation ship types. eg '- A relationship Belongs _ To of hourly _ Emp, Generalization of Bt feithe: reverse process of specialization Several classes With common features are genera lized Into Super cles, | €9:- cae, Truck generalized in to Vehicles Constraints fallzation - TE we can determine | that will become and Generalization exactly those entitis members af each sub class by a conditlon, the cubcassea are called predicated - defined er condition defined! a gets o predicate _ defined subclass ; 23 ri#ing the predicate condi tien nert i the line attaching the cub class t0 its super class. | u . , 4 all Subclasses in gq gpecialization have membershiD condition on game attribute st the supe class Specialization [S called an ttripate- detined specialization &9, Sop ty pe Tf mo conditton determines mem bersh tp the sub class is colted __user- detined. Disforotress Constraint. Each ™ember an entity can be o a member Of ot mos4+ one of the subclass of the spectalization. Ph not dissoint, specialization [s over lap ping That ts the same entity aay _| be a member of more then one sub class of the specialization. Specified by _o in €8@. Comp letneess Constraint Total speci fies that every entity in the super cl433 must e a member of es shown some te BER gragram by double line. Par dial allows an entity pot to belong +o any of the cubciasseg Shown iy by Single ne _ _ Aattice » Hierachles 8 shared Sub cicsye, A subctass may iiself heave furthur subcias specified on it forms a hierachy ora tay Hierachy has Q constraint that ever Sub cl%s- has only One super class Csingle inheim, . Lattice , & Mb class can pe Suheians of more than one super ciass — Cmultipale inns, ub class with more anon one superticty Ss pe ow is called a Shared subckiss C Multiple in neritenc,) Top down conceptual re binement _pracess Tr Specialization, cotart with an entit type and then define Sub classes of the entity type by successive specialization | ottom u concep tual Khesis process t tn Generalization | Start with man enti tupes and generalize Those that -) ave Common properties. ~~ Cotegories Cur p Types) - We need to nadel @ _ gingl@ super tlass/ “_gubelsss relationship ith more than one guper class "| Super class con represent different _ entity types. = “Such a Subciess i Type: called ao category oF fileA eee Vanco D “typically TOS. a «Tn the formal model, rows are called tuples — . Bn the formal model, the column header | is cabled (attri bute name) C jus 4 “attri puke) —_ Key of a relation: a [cca aa Ones oe voaue of a data them ahet —lunigutely Iden tiftes that __ros_in_the table ed~ the key eG “Sometimes row- Ads or sequen tial numbers ore asstgned ag keys £o identify the Tows in & table called ortificgal key or Surrogate key Domain Domain has a Jogical detinitio) Domain has a Aata-type Br formal The _attripute name lesignates the role old by a domalo 10 @ relation 700 The torte sian attri relation but eg. There are the 9 | 2) > Pro the domain state product oF = is a Subset OF the The domain of its main tyres of Constraints by relational Model key constraint Entity iotegrity cons train Referential inkerg ity Eve value 19 @ tuple must be trom of tg Super vey Ds : width Stote Su Any O89) Hse 45g the Attrs bude 4 adiributes Se of Q Foon. TNO tWo on wuples to any Walid relationa *CR\ will have the same values ter ti (sey ¢ ta [sk] set of attri putes that Or ikey 15 Bo minimal any Key Tf a Mes, one is phe identity primar 2ach includes Oo super key Super hey ts relation has also ow hey Severa] Candidate chosen ar bi varily tho be hey Tt ts Used uniquely tuple in a ve lation Eotit Th tegrit The Primary key Attribute Sof welarsoo Schemes R in Sf each cannot have null values in any +touple otf ~CR) c Ceky x nv. “Qe ferential integrity Tuples io the referencing relation RY nave attributes FC Foriegn key) thet weterence the vena kes artriputes Plc ce =o ry) 4 of the veferenced relarsion @ 2. 4, CFK = te C PKI The value in tre fortegn key coloumn Fk ot the referencing retarion @ 1 ean be, - case t 2 a value of On existing Primary key value of a corresponding primary hey PK in the referenced relation @2 , case 2 ee Te case of integrvity vidlatisn 1 several action can be taken Prenat tae ee ees eS tate errery ve . Peccsnn the operation bud inform the user of the violation + Trigger additiong] updates $9 the yiglartoe iS correct . y z Execute o wer -specitredt @yror corsecdion routine ER- co - eetational Mapping Algorithm Step \:- Mapping of Regular Entity ty peg For each yeguiar entity tyre ER schema, relation Simple attributes in the R that of &. create a inctudes all choose one of the (ey attributes of £ OS the .primary vey for R® Key Constraint A__foriegn hey tables ‘SO key used £0 link two A_foriegn -key 5 a fletd that iP one table refers to the Primery key in another | table. _ _We cannot indleate any Value in the referencing table that doesn’t have ony_value in veterenced table. step 2. Mapping of WeeK Eo tity types For each week entity type Wi in the ee Schema wyth Owner entity @ . create _Q ‘Yelatlon eg g Include ait Simple attribute Bectude as Foriegn Key attribuies of & jhe 7 3 Of the relatven that correspond = wer enay by types thet Gis oe RQ the combination of the primary key ot ine owner and the partial key of the week entity Lv Kala e Step 3:- Mapping of Binary wl Relation nae Types _ = rity the relations $ and 7 that den corres pond to the entity +9pesS There are 3 possible a pprowch D Foriegn key Ap proach Merged Relation Option _ Cross Reference Relation option, At Ha pping ot Binar SY es _ va Ddentify the retation S$ _ that rep resent Relationship the porttcipating entity type at the N. side Ob the relationship 2 7 10 S the primary ey of the relation T thar represen ts the other entity EYP! porticipating 19 R. Tneude aS foriegn tep 5 .- Mappin Create a new relotion SG to represen} R TMoclude as fortegn hey attrib utes ms the primary keys of the relations Fhat | represeni the participating entity types oo Also include any simpie _Ottributes of MON re lationship by re a3 Attributes Oi Ss of Binary MN Step 6'- Mapping oF Multiveluea attributes C For each mult} valued attvibute A, create a new relation RR Ths @. wi tnetude on e4trinute corresponding —__ bo A > Plug the primary key dettyibute fc rs a Foriegn ye. in R of tne relation thag wepresents the enrlay type of relotonship type thot has pias an attribute Stee z:- Mapping ot N-ory Relationship Types Create A new yelattonship S to ‘xe Present @ Include G5 Fk attribuies i 3 the Pk of the te relations thas represerts the partis, entity £4 pes Also include simple attributes 04 the 1 -ory relasionship type. ER-_to Peta ttan Step B:- Option for MaPPing Spectatizar, OY Generalization @y Multipte relations - Super — cdass and Sub - class Create a relation L for C with attributes Attrs CO) + fk, a: an} and PKCLD-k Creole a relation Li for each subclass St, Vk Fem vite sme attributes Attys CLi) “ii U Lattroutes of SiG and PK ELID-k This Op ton Works fo5y ONY Specializarion Ctotal or par aial dis foind of over- tapping) Wultiple relations - Subclass TE tations only Create a relation Lr for each subclass Si, 1Lidm, with the attributes Attr cu). Lattributes of F¥vuLb,a,--. an} and Pk Eri ue _ This option only works for a specia zation whose subclasseS are cotal Cevery entity super class must belong > foe Car teas +) the gubctass. J) _ | Ging le rela tian with one | €reate_a_single _relosion —_1_ with attributes — Arars Ct) 2 4, a, --.an3 Ug attribute of S14 type. attri bute | | UU Gattributes o & Sm5 U LEX and PUCHIEh jeanes attribute + (5 called a *ype attribute | ll that indicates fhe subclass to nhich zach | bup te belongs. __ __1ng le relation _vaiith multiple tyPe attribute. | ereate a 8°99 le relation schema Lb With Oty putes Arty ctu, 4-9¥ Sastnilbuies %F Si} | Ue UC athipute of Sm yu Lert Rand | _ 7 ba, 22 tm Peak 7 bach HH 1 elem £54 boolean type attri bute indicating wheather o tup le belongs to the Sub class S! Step A'- Mapping of Union Types For mapping 9 category whose defining super class have different keys, it _ts customary to specify @ new key Ott bude called Surrogate key, when creating gq relation to correspond to the category . Relational Algebra Unorg Retation . % Relation atgebra is the basic set of operations for the relational model. x These operations enable 2 user tO Specify basic yetrieval request Cor queries) x These algebra operations thus produce new _telationg These can be furthur manipulated using operations of the game algebra * A sequence of relational aigebra operations forms a relational algebra =x pression. | nar: Relational Operations | S€LecT a Fal The select operation Co) is used to select a subset of the tuples from a relation basecl eon a Selection condition. ry The setect condition actS as a_ filter keeps onty those tuples that satis ty the qualifying condi ti0n eg.- O DNO-= 4 C emMPLovee) © SALARY > 30 000 Cemerovee) | Properties of Select Operations d OL Gelecttonconditioos CR) Produces a relation G that has the same schema as 2) Select {8 commutative 6 kL condition > CF £ condition 3 CRD Jo Zeondition a> C 6k condition: sca) Because of this Property, a casecchele Of Select operations may hve wo app ied to order : ae ares © Leomdiol oe cond2 3 64 condad(@) Kerd > Aya, cond2> AND ec gordas C22) PROSEcT nL attributelist > CRD The project operation removes any duplicate tuples. This is be cause the result oF the Project Operation must be a set of tuples, Progect creates a vertical participating — the ist ©f specified ggioumns {$ kept in each touple- The other attributes in each tuple ore discarded. Properties of PROTEcT oPeration . - The number of touple in the result of projection X Lattrivud elist> Ce) 8 always tess or equal 40 number of tuples io R PROJECT is not commutative Most Of 4he time want +0 apply Several relational - algebra Operations one after the other. To retrieve the First name, last name and salay Of all employees who work tn departm ent numbers wie must apply 4 select and Proyect operations. Rename, L-NAME SALARY C Opno-5 CEMPIDYEE) ) or we can explicity Show the sequence of operations, giving _a_name to each inter mediate relation « _ DEP 5 EMPS — TF puo -5 C EMPLOYEE) Resor — *eNAME LNANE, SALARY CaP 5ENPS) - ENAME — Ris denoted the RENAME _ operator The—ge In some cases we may Hen+ to “rename attributes of a re lation or the relation _narne or both. Psc a, 6s, Ba dced _ changes both: the relation name to S$, and _ the _coloumn Gattribute) names tO Bi, B2, ~-- BN PscRd “changes the relation name only fo Ss PC Br 82 Bn) C8) changes: +ne coloumn (attribute) names only 10 Bi, B2 Bu Oo SFeretio Relational Algebra Operations Fron SET Theory 2 D_ UNtToN CU) _ _ D mnteesecr ¢ N) DD Deer caence C2) D caatesscan PQonuct Union - _ * denoted by VU + The Besutt of RUS is oa relation that ‘includes all tuples that are either in R 6r in S or in both @ and g 4 The two operard yeltations @ and § must be * ty pe Compatible” Cor UNTON com patible) * Rand 6 must have came number. of attributes Egt- a DEPSFEMPS — Sono-5 CemPLoyee) REsuiti — xsow Caer Sempes) Resuito wmCesn) — x supeassw Coep & emes) Reso pesurtiy eesurta Tyee Compatibility Type _compability of operands is Yequired for the binary set Operation ONIon Calso others) OL CAL Aa, ___ pn) and @2C By Baie eae type compabl bte -4 * they have ‘the same number ot attributes, and * the domain of Corresponding attributes are ty pe compa ti ble. Caom(At)= domCer)iitor f-12,----n) ~ x SET DIFFERENCE LNT €eSEection TRLEPSEC TION denoted by O - - The result of the operatioo RNS- isa relation that includes all tuples that Gre in both R and GS _ = The two operand relations Rand S Must be “type compatible” _denoted by - The result R-S ts a relation that includes call tuples that ore tn R but not ings The two operand relations Rand 5s “type corn potible”, TA is more “different from the other 3 - The Properties of UNTon, TNTESECTLON DEFFECEN BUS + Sue and ROS> SQ D eGvt) = (eus)ut — @asdat - @nesat) > Q-5 #s-R CA SstAN PRODUCT | This Operation ts used to combine tuples from trio relations in oa combinatorial Sashiog PCa er On) «x S CBr Ba am) iPeculti eis a relation Q with degree nem att riputes QCA Pr. Po, B Ba _ Bm) Ml have mR * ng tuptes RxS wi The two operand do not have 0 he ” “Type compatible Eq :- FEMALE _ E€NPS & ocex = *F” (Eveioves) CHP NAMES €_ xename, Name SSM Cremace — cud EMP pereNaents — EMP WANES * DEPENDEN, ko keep OMY dombinationg Where the Dependent ts rvelated to the Employee | We add select operation: ag Follows ACTUAL. DES & Co csne essn CEM BEPEnsENTs) Resort — APNAME, LNAME DEPENDENT - NAME CAcruAL_ Dees) nee Relattonal erations Soto 2) Division Join denoted by pd The sequence o¢ Cartesian Product tougwed by select is used quite commonly to ident! fy and select related tuples from two relationg ‘This operation ts very fro por tant for ony relational DB With more khan one. Single relation becouse i ollons Ug com bine retateck tuples from various relattong Rw 4 joincwondition 5 S eg) - Suppose that we name ot the manag er of DEPT _ MGR & department wm Naassn = SON Empey retrive the wand +0 cach department Rx An) M2.A1-5.83 $ CB, B2,._ Bm) _ Result iS ao relation Q with degree O+M _ attributes = aa az. AM, 8 62, ... Bw) , Io thot order resulting Belation state has one taple the _ for each combination of uples - ¥ from Rand 5 Srom SG, but only Tf ‘they satisfy the join condition vCard. 5 [iJ . pR* nS tuple + The general case of IJOFN operation is cated Theta - Join a2 We S general booleon ex pression an Theta con be “ary the attributes of RandS eg: - R. ATLS. Bi AND Re pp LS. 84) QR. AiLS-87 AND R-Ak =S.BL AND RAP SS. Bq Ce-Ak=S- BL oa E€Qisomn - The most Common use of foln involes jot conditions With equality com Parisons on ly EB To the yesul4 of +hi5 we always have ore or more pairs of attributes that have identical values in every tuple Notural Join + denoted by * Was created to get rid ot she second attri bute in on EQUT Soin condition. Natural Join requires that the two fotn attributes or each palr of corresponding Join attributes, hove the same name in both retationg Fa'- 9 Io apply fatural jos on she ONUMBES attributes Of DEPARTMENT and Oe et = LocatHtans DEPF_ Locs DEPARTMENT yg DE PT_ Loca Tron D9 @e— CCA Bc ada sCc a, e) ReCe S.c AND 2.0"5.9 Complete Set OF Petational Operattons ROS 2 Ceus)- Ccees) UG - 2) RW < soroconditions ¢ S Lsoimcondittony C2 XS) wa ®IVISION — ecz) 4 5Cxd viheve Xx subset Zz. lek se c-6 Co 7 of oivision ig g relation CY) + if tuples te appear te CxJ ets The result thot imctudeS a tuple in @ with telYT~ bond wit for every tuple ts tt GS. in the cesult Toft For & tuple 4 +0 appear the Diviston, the values to <4 t must appear in R'm combination pith every tuple in S. Examples Retrieve the Name and address of all the “ Research employees who work for Department! Research. Dept S— Taname - Research’ Department) Research, EMPS GC C Research DePt MW Emploge number =9N0 Result €- x Frame, Lname, Address C@eseorch EMS) KEneme, Lmame, Address C TBname = “Pe search"( Department HR) — CEay > ‘Doumber~ow

You might also like