BASIC CONCEPTS OF DATABASE

Embed Size (px)

Citation preview

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    1/16

    ENTITY

    RELASHIONSHIPERD MODEL

    MUHAMMAD SHAFIQIIU ISLAMABADPAKISTAN

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    2/16

    ER MODEL

    An entity-relationship model (E-R model) is adetailed, logial !e"!esentation o# t$edata #o! an o!gani%ation o! #o! a &'siness a!ea(

     T$e E)R *odel is e+"!essed in te!*s o# 

    entities in t$e &'siness eni!on*ent, t$e !elations$i"s-o! assoiations. a*ong t$ose

    entities, and t$e att!i&'tes -o! "!o"e!ties. o# &ot$ t$eentities and t$ei! !elations$i"s(

    An E)R *odel is no!*all/ e+"!essed as an entity-

    relationship diagram (E-R diagram, orERD), 0$i$ is a g!a"$ial !e"!esentation o# an E)R*odel(

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    3/16

    Entit/

    EntityA "e!son, a "lae, an o&1et,

    an eent, o! a one"t in t$e'se! eni!on*ent a&o't 0$i$t$e o!gani%ation 0is$es to

    *aintain data(

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    4/16

    Entit/ T/"e

    Entity typeA olletion o# entities t$ats$a!e o**on "!o"e!ties o!

    $a!ate!istis(

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    5/16

    Entit/ Instane

    Entity instanceA single o'!!ene o# anentit/ t/"e(

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    6/16

    ENTITY TYPE VERSS ENTITYINST!N"E

     T$e!e is an i*"o!tant distintion &et0eenentit/ t/"es and entit/ instanes(

    An entity type is a olletion o# entities t$at s$a!eo**on "!o"e!ties o! $a!ate!istis(

    Ea$ entit/ t/"e in an E)R *odel is gien a na*e(Bea'se t$e na*e !e"!esents a olletion -o! set. o#ite*s, it is al0a/s sing'la!(

    2e 'se a"ital lette!s #o! na*es o# entit/ t/"e-s.( In

    an E)R diag!a*, t$e entit/ na*e is "laedinside t$e &o+ !e"!esenting t$e entit/ t/"e(

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    7/16

    ENTITY TYPE VERSS ENTITYINST!N"E

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    8/16

    Data Mani"'lation in DBMS

    Data *ani"'lation in DBMS is di3e!ent #!o* data*ani"'lation in 4le s/ste* (

    DBMS *ani"'lates data as #ollo0s5

    It sto!e and *ani"'lates data in ta&les o! !elations(

    DBMS *a/ onsist o# one o! *an/ t$!o'g$ di3e!ent( T$e !elations in DBMS a!e onneted t$!o'g$di3e!ent t/"es o# !elations$i"s(

    DBMS 'ses inde+ to sea!$ t$e !e6'i!ed data6'i7l/ and e8ientl/ (

    DBMS 's'all/ 'se! STRU9UTRE QUERY LAN:UATE-SQL. to "e!#o*e di3e!ent o"e!ations in t$e data

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    9/16

    Data #anip$lation inD%#S DBMS "!oides t$e #ailit/ to inse!t ne0

    data in data&ase

    DBMS "!oides t$e #ailit/ to !et!iee t$e

    e+isting data #!o* t$e data&ase DBMS "!oides t$e #ailit/ to delete

    e+isting data #!o* data&ase(

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    10/16

    RE&!TI'N!& D!T!STR"TRE A relation is a na*ed, t0o)di*ensional ta&le o# data( Ea$ !elation -o! ta&le. onsists o# a set o# na*ed ol'*ns and

    an a!&it!a!/ n'*&e! o# 'nna*ed !o0s(

    An att!i&'te, is a na*ed ol'*n o# a !elation(

    Ea$ !o0 o# a !elation o!!es"onds to a !eo!d t$at ontains data-att!i&'te. al'es #o! a single entit/(

    Fig'!e ;)< s$o0s an e+a*"le o# a !elation na*edEMPLOYEE

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    11/16

    Fig'!e ;(<

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    12/16

    RE&!TI'N!& D!T!STR"TRE No! does deleting a !o0 $ange t$e !elation( In

    #at, 0e o'ld delete all o# t$e !o0s s$o0n inFig'!e ;)

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    13/16

    Primary ey in Relational Dataase

    A primary ey is an att!i&'te o! ao*&ination o# att!i&'tes t$at 'ni6'el/identi4es ea$ !o0 in a !elation( 2e designatea "!i*a!/ 7e/ &/ 'nde!lining t$e att!i&'tena*e-s.(

    Fo! e+a*"le, t$e "!i*a!/ 7e/ #o! t$e !elationEMPLOYEE< is E*"ID( Notie t$at t$is

    att!i&'te is 'nde!lined in Fig'!e ;)

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    14/16

    P!i*a!/ 7e/ in Relational Data&ase

    The concept o* a primary ey is related to the term identiferde+ned in "hapter

    The same attri$te or a collection o* attri$tes indicated as anentity.s identi+er in an E-R diagram may e the sameattri$tes that compose the primary ey *or the relation

    representing that entity There are e/ceptions0 1or e/ample, associati2e entities do not

    ha2e to ha2e an identi+er, and the (partial) identi+er o* a3ea entity *orms only part o* a 3ea entity.s primary ey

    In addition, there may e se2eral attri$tes o* an entity

    that may ser2e as the associated relation.s primary ey !ll o*these sit$ations 3ill eill$strated later in this chapter

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    15/16

    9o*"osite "!i*a!/ 7e/

    A composite ey is a "!i*a!/ 7e/ t$atonsists o# *o!e t$an one att!i&'te( Fo!e+a*"le, t$e "!i*a!/ 7e/ #o! a !elation

    DEPENDENT 0o'ld li7el/ onsist o# t$eo*&ination E*"ID andDe"endentNa*e(

  • 8/16/2019 BASIC CONCEPTS OF DATABASE

    16/16

    1oreign ey in RelationDataase A *oreign ey is an att!i&'te -"ossi&l/

    o*"osite. in a !elation t$at se!es ast$e "!i*a!/ 7e/ o# anot$e! !elation( Fo!

    e+a*"le,onside! t$e !elations EMPLOYEE< andDEPARTMENT5