Top Banner

of 21

Implementing the Physical Database.doc

Jun 04, 2018

Download

Documents

divandann
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/14/2019 Implementing the Physical Database.doc

    1/21

    Implementing the Physical DatabaseDate: Nov 11, 2005 ByThomas Moore, Ed Tittel. Sample Chapter is provided cortesy o! "e.This chapter deals #ith the physical compo$e$ts o! a S"% Server data&ase system. Be'i$$i$' #ith the server hard#are, or'a$i(i$'the data stora'e a$d creati$' the physical !iles is #here a lot o! !tre per!orma$ce #ill &e determi$ed.

    Terms you'll need to understand:

    )*+D

    i'a&it

    Data&ase

    Ta&le

    )ecord

    )o#

    Colm$

    -ield

    -ile'rops

    Clstered i$de

    No$clstered i$de

    Tri''er

    /rimary ey

    -orei'$ ey

    Co$strai$t

    Stored procedre

    %o' !ile

    Model data&ase

    Techniques you'll need to master:

    ard#are setp!ile placeme$t

    Data&ase creatio$

    3&4ect creatio$

    Setti$'alteri$' properties

    Setti$' co$strai$ts

    Introduction

    This chapter deals #ith the physical compo$e$ts o! a S"% Server data&ase system. Be'i$$i$' #ith the server hard#are, or'a$i(i$'the data stora'e a$d creati$' the physical !iles is #here a lot o! !tre per!orma$ce #ill &e determi$ed. There are ma$y optio$s to

    http://www.informit.com/authors/bio.asp?a=38fd7e0b-be25-4eda-ac2b-9c98ea19871chttp://www.informit.com/authors/bio.asp?a=38fd7e0b-be25-4eda-ac2b-9c98ea19871chttp://www.informit.com/authors/bio.asp?a=6491b443-ec58-44b7-a7fc-f2f95c53100dhttp://www.quepublishing.com/http://www.quepublishing.com/http://www.informit.com/index.asphttp://www.informit.com/authors/bio.asp?a=38fd7e0b-be25-4eda-ac2b-9c98ea19871chttp://www.informit.com/authors/bio.asp?a=6491b443-ec58-44b7-a7fc-f2f95c53100dhttp://www.quepublishing.com/
  • 8/14/2019 Implementing the Physical Database.doc

    2/21

    co$sider !or a prodctio$ e$viro$me$t, a$d o$e thi$' is certai$: The mi$imm i$stallatio$ reireme$ts #ill $ot &e s!!icie$t. Thecompter hard#are compo$e$ts are o$ly the &e'i$$i$' o! the physical eleme$ts.

    *ltho'h #e te$d to thi$ o! the physical realm as thi$'s that #e ca$ toch a$d !eel, #ithi$ a DBMS e$viro$me$t it also de!i$es thecompo$e$ts o! the data&ase itsel!. The data&ase layot, the ey strctres, co$strai$ts, a$d other so!t#are eleme$ts are all co$sideredphysical eleme$ts. +t6s time !or the e$tities discssed i$ the lo'ical desi'$ to &ecome ta&les.

    +$ a$y physical desi'$, the 'oal is to provide a$ e!!icie$t a$d respo$sive data&ase system that also le$ds itsel! to appropriatemai$te$a$ce tass #ithot &ecomi$' a data&ase admi$istrator6s &rde$. *t this sta'e o! a data&ase impleme$tatio$, care is tae$ toprovide a system strctre that is sa&le, provides !or optimm ser respo$se time, ca$ &e readily mai$tai$ed, a$d a&ove all meets the

    $eeds o! the &si$ess !or #hich it #as desi'$ed.

    +$ movi$' !rom a$ idea to a lo'ical strctre to the actal physical eleme$ts, yo mst remem&er to co$sider eleme$ts that co$tri&teto per!orma$ce, relia&ility, a$d data i$te'rity. avi$' a model o! the system is o$e thi$', &t it mst &e a&le to meet the dema$ds o! a$e$viro$me$t i$ #hich i$evita&ly the system mst meet the i$te$ded 'oals o! the compa$y a$d add to the &ottom li$e.

    +$ a &oo o! this $atre, tryi$' to !it all topics i$to the !ray i$ a lo'ical ma$$er ca$ sometimes &e a##ard. +$ this chapter #e #illdiscss some o! the hard#are impleme$tatio$s that pro&a&ly shold #ait !or a data&ase desi'$ a$d other criteria. 7e #ill approach thehard#are $et !rom a sta$dpoi$t o! #hat the &aseli$e rles are !or esta&lishi$' the server.

    A Hardware Dialogue

    +$ a prodctio$ e$viro$me$t, &d'et is 'oi$' to limit some o! the hard#are decisio$s &ei$' made. 3!te$, $e# hard#are is$6t eve$

    co$sidered, tho'h i$ ma$y cases it is $eeded. %et s approach the topic !irst !rom a mi$imm hard#are perspective a$d the$pro'ress to a sal or &est8practice sce$ario. -i$ally, #e #ill loo at the optimm hard#are9the hard#are #e #old choose i! there#ere a very lar'e &d'et availa&le to cover eipme$t costs.

    %et6s start #ith somethi$' that may &e !o$d o$ the *dmi$istratio$ eam, tho'h less liely see$ #ithi$ the desi'$ topics. These arethe mi$imm reireme$ts as speci!ied &y Microso!t:

    /e$tim 1M( or hi'her

    ;MB mi$imm, 12

  • 8/14/2019 Implementing the Physical Database.doc

    3/21

    * 'i'a&it &ac&o$e shold &e co$!i'red !or the $et#or aro$d the server. +t is eve$ #orth co$sideri$' mltiple $et#or cardsco$$ected to the server to i$crease the &a$d#idth availa&le to the machi$e.

    +! yo are looi$' o$ the very hi'h e$d, the$ t#o sets o! small )*+D arrays o! three drives, each o$ t#o separate co$trollers, ca$provide some additio$al per!orma$ce 'ai$ a$d !lei&ility #ith data a$d i$de placeme$t. +t is also o!te$ recomme$ded that the lo' !iles&e ept separated !rom the data so as to improve per!orma$ce a$d redce dis co$te$tio$.

    TIP

    eepi$' the lo' !iles separate !rom the data ca$ help improve per!orma$ce a$d redce dis co$te$tio$.

    Defining a SQL Server Database

    * data&ase is similar to a #or !ile !older, #hich co$tai$s i$!ormatio$ pertai$i$' to related topics. +$ the same #ay, a data&ase is a'rop o! !iles sed to store data pertai$i$' to a si$'le &si$ess process. Data&ases are or'a$i(ed #ith !ields, records, a$d ta&les. *!ield is a si$'le characteristic, attri&te, or property that provides i$!ormatio$ a&ot a$ o&4ect. * record is a complete set o! all the !ieldscom&i$ed to'ether !or a particlar o&4ect. * ta&le is a 'rop o! all related records.

    S"% Server is a relatio$al data&ase ma$a'eme$t system. * relatio$al data&ase co$tai$ed #ithi$ S"% Server is a collectio$ o! o&4ectsi$ #hich data a$d other i$!ormatio$ are stored i$ mltiple ta&les. The $meros ta&les are related i$ some #ay, either directly ori$directly via other ta&les. * relatio$al data&ase co$tai$s all data&ase o&4ects, strctres, a$d ra# data pertai$i$' to that data&ase.

    Becase #e have 4st looed at the hard#are, let6s start #ith a !ocs o$ #here to pt the !iles !or the data&ase server. 3! co$sideratio$here are the operati$'8system !iles, the applicatio$ pro'ram !iles, a$d the data&ase !iles co$sisti$' o! t#o types o! !iles: data filesandlog files.

    +t is also #orth co$sideri$' the separatio$ o! i$dees &ecase some per!orma$ce 'ai$s ca$ &e reali(ed i! the i$dees are stored o$ adrive other tha$ the o$e o$ #hich the data is stored. This is do$e thro'h the se o! !ile'rops. 7he$ the i$de is created o$ adi!!ere$t !ile'rop, each 'rop ca$ mae se o! di!!ere$t physical drives a$d their o#$ co$trollers. Data a$d i$de i$!ormatio$ ca$ the$&e read i$ parallel &y mltiple dis heads.

    +$ a$ ideal co$!i'ratio$ some#hat to$'e i$ chee, yo mi'ht #a$t to separate the operati$' system !rom its pa'e !ile. o #oldthe$ place the lo' o$to its o$e drive, separate !rom the data, #ith the data co$!i'red over a )*+D volme as descri&ed i$ the !ollo#i$'sectio$. o6d the$ tae the seldom8sed data colm$ or ta&le data a$d separate it !rom data that #ill &e accessed more !ree$tly.

    *!ter placi$' the i$dees o!! o$ their o#$ volme as #ell, !or a&ot F150,000>F200,000 yo #old have the optimm per!orma$ce i$ adata&ase server.

    )emem&er that the DBMS #ill rely heavily o$ the !ile system. The !ile !ormat i$ S"% Server 2000 has $ot si'$i!ica$tly cha$'ed !rom theprevios versio$ S"% Server ?. S"% Server ses a set o! !iles to store the data, i$dees, a$d lo' i$!ormatio$ !or a data&ase. *primary !ile also has some header i$!ormatio$ i$ it, providi$' S"% Server #ith $ecessary i$!ormatio$ a&ot a data&ase. Each data&asehas a mi$imm o! t#o !iles associated #ith it, o$e !or the data a$d a seco$d !or the lo'. +t is also possi&le to create mltiple !iles !oreach o! these prposes as descri&ed i$ the !ollo#i$' para'raphs. -ile placeme$t, a$d o&4ect placeme$t #ithi$ these !iles, plays a$importa$t role i$ the respo$sive$ess o! S"% Server. * data&ase co$sists o! t#o or more !iles #ith each !ile sed !or o$ly a si$'ledata&ase. * si$'le !ile ca$$ot &e shared &y mltiple data&ases.

    The ile System

    Each data&ase has o$e or more !iles sed to store i$dees a$d data. +$ a lot o! data&ase sce$arios, yo #ill $ot impleme$t more tha$o$e data !ile a$d o$e lo' !ile. +$ some i$sta$ces, ho#ever, yo mi'ht #a$t to impleme$t a !ile'rop. o mi'ht also have a

    per!orma$ce 'ai$ thro'h the appropriate placeme$t o! o&4ects #ithi$ these 'rops.

    The !irst !ile created !or this prpose is re!erred to as the primary file. The primary !ile co$tai$s the i$!ormatio$ $eeded to start p adata&ase a$d is also sed to store some or all o! the data. +! desired, seco$dary !iles ca$ &e created to hold some o! the data a$d othero&4ects. Some data&ases mi'ht &e lar'e e$o'h or comple e$o'h i$ their desi'$ to have mltiple seco$dary !iles sed !or stora'e.Normally, the lo' is mai$tai$ed i$ a si$'le !ile. The lo' !ile is sed to store cha$'es to the data&ase &e!ore these cha$'es are recordedi$ the data !iles themselves. The stora'e o! i$!ormatio$ i$to lo' !iles i$ this ma$$er e$a&les S"% Server to se these !iles as a$importa$t part o! its recovery process. Every time the S"% Server is started, it ses the lo' !iles !or each o! the data&ases to determi$e#hat $its o! #or #ere still &ei$' ha$dled at the time the server #as stopped.

    The !ile$ames 'ive$ to all data a$d lo' !iles ca$ &e a$y desired $ame, altho'h it is recomme$ded that yo select a $ame thati$dicates the co$te$t o! the !ile. The !ile ete$sio$s !or the primary data !ile, seco$dary data !iles, a$d lo' !iles ca$ also &e a$y chose$set o! characters. +t is recomme$ded !or co$siste$cy a$d sta$dardi(atio$ that the ete$sio$s &e .md!, .$d!, a$d .ld! !or the primary,seco$dary, a$d lo' !iles, respectively.

    !reating iles and ilegroups

    -ile'rops e$a&le a 'rop o! !iles to &e ha$dled as a si$'le $it, a$d ths mae impleme$tatio$s that reire mltiple !iles easier toaccommodate. 7ith !ile'rops, S"% Server provides a$ admi$istrative mecha$ism o! 'ropi$' !iles #ithi$ a data&ase. o mi'ht #a$t

  • 8/14/2019 Implementing the Physical Database.doc

    4/21

    to impleme$t !ile'rops to spread data across more tha$ o$e lo'ical dis partitio$ or physical dis drive. +$ some cases, this provides!or i$creased per!orma$ce as lo$' as the hard#are is s!!icie$t to optimi(e readi$' a$d #riti$' to mltiple drives co$crre$tly.

    o ca$ create a !ile'rop #he$ a data&ase is created, or yo mi'ht add them later #he$ more !iles are $eeded or desired. *!ter a!ile'rop has &ee$ assi'$ed to a data&ase, yo ca$$ot move its !iles to a di!!ere$t !ile'rop. There!ore, a !ile ca$$ot &e a mem&er o!more tha$ o$e !ile'rop. S"% Server provides !or a lot o! !lei&ility i$ the impleme$tatio$ o! !ile'rops. Ta&les, i$dees, tet, $tet, a$dima'e data ca$ &e associated #ith a speci!ic !ile'rop, allocati$' all pa'es to o$e speci!ic 'rop. -ile'rops ca$ co$tai$ o$ly data !ilesGlo' !iles ca$$ot &e part o! a !ile'rop.

    +! yo place i$dees i$to their o#$ !ile'rop, the i$de a$d data pa'es ca$ &e ha$dled as separate physical read eleme$ts. +! the

    associated !ile'rops are placed o$to separate physical devices, each ca$ &e read #ithot i$ter!eri$' #ith the readi$' o! the other.This is to say that #hile a$ i$de is read thro'h i$ a see$tial ma$$er, the data ca$ &e accessed ra$domly #ithot the $eed !orma$iplati$' the physical arm o! a hard drive &ac a$d !orth !rom the i$de a$d the data. This ca$ improve per!orma$ce a$d at thesame time save o$ hard#are #ear a$d tear.

    /laci$' a$ e$tire ta&le o$to its o#$ !ile'rop o!!ers ma$y &e$e!its. +! yo do so, yo ca$ &ac p a ta&le #ithot havi$' to per!orm amch lar'er &acp operatio$. *rchived or seldom8sed data ca$ &e separated !rom the data that is more readily $eeded. 3! corse,the reverse is tre: * ta&le that $eeds to &e more readily availa&le #ithi$ a data&ase ca$ &e placed i$to its o#$ !ile'rop to e$a&leicer access. +$ ma$y i$sta$ces, pla$$ed de$ormali(atio$ the prpose!l creatio$ o! red$da$t data ca$ &e com&i$ed #ith this!eatre to o&tai$ the &est respo$se.

    /laci$' tet, $tet, a$d ima'e data i$ their o#$ !ile'rop ca$ improve applicatio$ per!orma$ce. Co$sider a$ applicatio$ desi'$ thatallo#s the data !or these colm$ types to &e !etched o$ly po$ ser reest. -ree$tly, it is $ot $ecessary !or a ser to vie# pictresa$d ete$sive $otes #ithi$ a sta$dard ery. Not o$ly does this accommodate &etter8per!ormi$' hard#are, &t it also ca$ provide

    !aster ery respo$ses a$d less &a$d#idth satratio$, &ecase data that is $ot reired is $ot se$t across the $et#or.

    -ile'rops ca$ provide !or a more e!!ective &acp strate'y !or lar'er data&ase e$viro$me$ts. +! a lar'e data&ase is placed acrossmltiple !ile'rops, the data&ase ca$ &e &aced p i$ smaller pieces. This is a$ importa$t aspect i! the time to per!orm a !ll &acp o!the e$tire data&ase is too le$'thy.

    *!ter a determi$atio$ has &ee$ made to se a !ile'rop strate'y !or stori$' data, al#ays e$sre that #he$ a &acp is per!ormeda'ai$st a !ile'rop the i$dees are also &aced p at the same time. This is easily accomplished i! the data a$d i$dees are stored i$the same !ile'rop. +! they are located o$ separate !ile'rops, e$sre that &oth the data a$d the i$de !ile'rops are i$clded i$ asi$'le &acp operatio$. Be a#are that S"% Server does $ot e$!orce &acp o! data a$d i$de !ile'rops i$ a si$'le operatio$. omst e$sre that the !iles associated #ith the i$dees tied to a particlar dataset are &aced p #ith the data dri$' a !ile'rop &acp.

    3&4ects ca$ easily &e moved !rom o$e !ile'rop to a$other. Hsi$' the appropriate property pa'e, yo 4st select the $e# !ile'rop i$to

    #hich yo #a$t to move the o&4ect. %o's are $ot stored i$ !ile'rops. o ca$, ho#ever, se mltiple lo' !iles a$d place them i$di!!ere$t locatio$s to o&tai$ &etter a$d more varied mai$te$a$ce a$d allo# more stora'e space !or lo' co$te$t.

    ile Placement for Performance and "eliability

    The placeme$t o! the !iles related to a S"% Server 2000 data&ase e$viro$me$t helps to e$sre optimm per!orma$ce #hile mi$imi(i$'admi$istratio$. )ecovera&ility ca$ also &e improved i$ the eve$t o! data corrptio$ or hard#are !ailres i! appropriate measres aretae$. 3$ the eam, yo mst &e prepared to respo$d to these reireme$ts a$d properly co$!i're the i$teractio$s #ith the !ilesystem.

    +t is a&soltely ma$datory to $dersta$d the &asics o! the !ile system a$d its se &y S"% Server. $o# #he$ to split o!! a portio$ o! thedata&ase strctre a$d stora'e to a separate physical dis drive. Ma$y processes per!ormed #ithi$ S"% Server ca$ &e classi!ied assee$tial or ra$dom. +$ a see$tial process, the data or !ile ca$ &e read i$ a !or#ard pro'ressio$ #ithot havi$' to locate the $et

    data to &e read. +$ a ra$dom process, the data is typically more spread ot, a$d 'etti$' at the actal physical data reires mltipleaccesses.

    7here possi&le, it is desira&le to eep see$tial processes r$$i$' #ithot physical i$terrptio$ cased &y other processesco$te$di$' !or the device. Hsi$' !ile placeme$t strate'ies to eep ra$dom processes separate !rom see$tial o$es e$a&les theco$!i'ratio$ to mi$imi(e the competitio$ over the placeme$t o! the read#rite heads.

    *s a mi$imm reireme$t !or almost a$y impleme$tatio$, yo shold separate the $ormal see$tial processi$' o! the lo' !iles !romthe ra$dom processi$' o! the data. o also improve recovera&ility &y separati$' the data !rom the lo' a$d placi$' them o$ separatephysical volmes. +! the volme #here the data is stored is dama'ed a$d mst &e restored !rom &acp, yo #ill still have access tothe last lo' e$tries. The !i$al lo' ca$ &e &aced p a$d restored a'ai$st the data&ase, #hich 'ives somethi$' very close to 100Irecovera&ility ri'ht to the poi$t o! !ailre.

    *$ i$teresti$' a$d !lei&le strate'y is to provide a separate drive solely !or the lo'. This si$'le volme does $ot have to participate i$)*+D architectre, &t )*+D mi'ht &e desired !or !ll recovera&ility. +! yo 'ive the lo' the space o! a$ e$tire volme, yo 'ive the lo'more room to 'ro# a$d accmlate over time #ithot the $eed !or periodic emptyi$'. %ess !ree$t lo' &acps are $eeded a$d the&est possi&le lo' per!orma$ce is achieved.

    T#o primary co$cer$s i$ most data e$viro$me$ts are data recovera&ility i$ the eve$t o! the i$evita&le !ailres a$d co$sideratio$s !ormi$imal do#$time. +$ the i$dstry, o$e o! the optimm rati$'s to strive !or is the elsive J!ive $i$esJ ==.===. This rati$' mea$s that

  • 8/14/2019 Implementing the Physical Database.doc

    5/21

    over a$y 'ive$ period a 'e$erally accepted sta$dard o! A5 days mi$imm, the server remai$ed o$li$e a$d servici$' the e$d ser==.===I o! the time. +$ other #ords, the total do#$time !or a$ e$tire year #old &e a little more tha$ !ive mi$tes.

    Database !reation

    *$ a&solte $ecessity o! &ildi$' data&ases that i$teract #ith S"% Server 2000 is si$' the appropriate data&ase o&4ects to o&tai$ asa&le data&ase system #hile improvi$' respo$se times a$d mai$tai$i$' data i$te'rity. There are co$sideratio$s a$d trade8o!!s !orchoosi$' o$e tech$ie over the other. The selectio$ o! the most appropriate method to o&tai$ the desired reslt reires that yo$o# #here each tech$ie is &est impleme$ted. The eam #ill test o$ the appropriate applicatio$ o! each o! these o&4ects.

    Creati$' a$d alteri$' data&ases i$volves selecti$' the physical volme type !or each data&ase !ile, setti$' the appropriate !ileproperties, placi$' the o&4ects i$to the !iles!ile'rops, a$d e$sri$' that appropriate ad4stme$ts are made as the data&ase matres.The type o! &si$ess $eeds that the data&ase is &ei$' desi'$ed to meet helps to i$dicate the measres $eeded to e$sre adeateper!orma$ce.

    Try to place o$to separate volmes a$y !iles that mi'ht te$d to compete #ith each other !or read cycles dri$' a si$'le operatio$. /lacelo' !iles a#ay !rom the data to e$sre adeate recovery, a$d mae sre that data&ase properties have &ee$ set i$ sch a #ay as toe$sre that mai$te$a$ce tass ca$ &e per!ormed.

    7he$ yo create a data&ase !or the !irst time, that data&ase i$itially taes most o! its attri&tes !rom the Model data&ase. The Modeldata&ase is a system data&ase that S"% Server ses as a i$d o! template !or data&ase creatio$s. +t is a 'ood a$d commo$ practice toset the properties a$d co$te$ts o! the Model data&ase &ased o$ the ma4ority o! $e# data&ases that are to &e created.

    +$ practice, ma$y o&4ects are stored i$ the Model data&ase to mi$imi(e the $eed to re8create these o&4ects every time a data&ase iscreated. Commo$ eleme$ts placed i$ the Model o!te$ i$clde speciali(ed ser8de!i$ed !$ctio$s a$d data types that are prese$t a$d!ree$tly sed &y the developme$t sta!! i$ their codi$'. +$ theory, o&4ects are created !or se i$ a si$'le data&ase, &t all developersreali(e that o&4ect a$d code rese is a$ importa$t !acet o! easi$' the developme$t process.

    3!te$ a$ o&4ect, sch as a ser8de!i$ed !$ctio$, sta$dard secrity role, or corporate i$!ormatio$ ta&le, ca$ &e !o$d i$ most i! $ot alldata&ases #ithi$ a compa$y. * property vale, sch as recovery level, mi'ht also have a sta$dard impleme$tatio$ across all servers i$the e$terprise. +! a$ o&4ect or a property vale #ill &e prese$t i$ most o! the ser data&ases, placi$' the o&4ect i$to the Model data&aseor setti$' a property accordi$'ly ca$ save yo the #or o! per!ormi$' the activity as a post8creatio$ tas.

    *ll !iles $eeded !or a data&ase ca$ &e created thro'h a si$'le activity si$' S"% Server6s E$terprise Ma$a'er as sho#$ i$-i'reA.1 or #ith a si$'le CREATE DATABASETra$sact S"% stateme$t. Either o! these methods ca$ &e sed to i$itiali(e all !iles a$dcreate the data&ase a$d lo's i$ a si$'le step.

    -i're A.1Data&ase creatio$ !rom the E$terprise Ma$a'er.

    S"% Server 2000 e$a&les yo to set data&ase !iles so that they epa$d a$d shri$ atomatically, elimi$ati$' the $eed !or additio$aladmi$istratio$. By de!alt, S"% Server e$a&les data !iles to i$crease i$ si(e as $eeded !or data stora'e. There!ore, a !ile ca$ 'ro# tothe poi$t #here all dis space is ehasted. o ca$ speci!y that a !ile is $ot to 'ro# &eyo$d its creatio$ si(e or impleme$t a maimm

    http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig01.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig01.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig01.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig01.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig01.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig01.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig01.jpg')
  • 8/14/2019 Implementing the Physical Database.doc

    6/21

    si(e !or !ile 'ro#th. E$sre that dis space is $ot ehasted &y si$' the MAXSIZEoptio$ o! the CREATE DATABASEor ALTERDATABASEstateme$ts to i$dicate the lar'est si(e to #hich a !ile ca$ 'ro#.

    The de!alt $ames !or the primary data&ase a$d tra$sactio$ lo' !iles are created si$' the data&ase $ame yo speci!ied as the pre!i9!or eample, NewDatabase_Data.mdf a$d NewDatabase_Log.ldf . These $ames a$d locatio$s ca$ &e cha$'ed, i!desired, !rom the de!alt vales provided !or the $e# data&ase !ile. The T8S"% sy$ta !or creati$' a simple data&ase is as !ollo#s:

    CREATE DATABASE MyDatabaseONNAME ! "DataSto#e$%

    &ILENAME ! "d'(data d)#e*to#y(DataSto#e_MyDatabase.mdf$% SIZE ! +MB% MAXSIZE ! ,MB% &ILE-ROT/ ! +MB0LO- ONNAME !$LogSto#e$% &ILENAME ! "e'(log d)#e*to#y(LogSto#e_MyDatabase.ldf$% SIZE ! +MB% MAXSIZE ! ,MB% &ILE-ROT/ ! +MB0

    -ollo#i$' are some importa$t isses #ith re'ard to appropriate se o! the C)E*TE D*T*B*SE stateme$t:

    The de!alt 'ro#th i$creme$t measre is MB, &t it ca$ also &e speci!ied #ith a B or a I s!!i. 7he$ I is speci!ied, the

    'ro#th i$creme$t si(e is the speci!ied perce$ta'e o! the si(e o! the !ile at the time the i$creme$t occrs.

    * maimm o! A2,?? data&ases ca$ &e de!i$ed o$ a server.

    The mi$imm si(e !or a lo' !ile is 512B.

    Each data&ase has a$ o#$er. The o#$er is the ser #ho creates the data&ase. The data&ase o#$er ca$ &e cha$'ed thro'h

    s1_*2a3gedbow3e#.

    The Master data&ase shold &e &aced p a!ter a ser data&ase is created.

    The de!alt $it o! measre !or the s)4ea$d ma5s)4esetti$'s is MB i! yo spply a $m&er, &t $o measre is provided. +!$o optio$s are spplied, ma5s)4ede!alts to 63l)m)teda$d the f)leg#owt2is +78.

    +$ a volatile e$viro$me$t, the data&ase a$d its related !iles mi'ht !ree$tly i$crease a$d decrease i$ si(e, a$d this activity mi'ht &ethe desired operatio$ o! the server. +$ most i$sta$ces, a$ impleme$tatio$ providi$' !or more sta&ility i$ the !ile system is the desiredreslt. * determi$atio$ has to &e made as to #hether the data&ase stays at a&ot the same si(e or 'ro#s or shri$s over time. +$ mostsce$arios, a data&ase 'ro#s over time a$d $eeds to &e redced o$ly #he$ data is archived.

    7he$ creati$' the !iles, yo shold set the SIZE, MAXSIZE, a$d &ILE-ROT/parameters so that the data&ase ca$ i$crease i$volme over time. The &ILE-ROT/co$!i'ratio$ shold &e impleme$ted i$ lar'er i$creme$ts so that 'ro#th #ithi$ the !ile systemis$6t occpyi$' too mch o! the server6s resorces. ro#th o! !iles occrs i$ the &ac'ro$d a$d ca$ &e mi$imi(ed &y si$' a lar'er'ro#th i$creme$t. *l#ays provide a MAXSIZEe$try eve$ i! the e$try itsel! is close to the capacity o! the volme.

    o ca$ se the CREATE DATABASEstateme$t to create a data&ase !rom script. Savi$' the script e$a&les yo to re8create a similardata&ase o$ a$other server i$ the !tre. *$y S"% Server o&4ect ca$ have its creatio$ script saved. Hsi$' the CREATE DATABASEstateme$t to create a data&ase si$' mltiple !iles a$d lo' !iles #old loo similar to this:

    CREATE DATABASE E5am1leON9RIMAR: NAME ! E5am1leData%&ILENAME ! "*'(mss;l(data(sam1dat.mdf$% SIZE ! +7MB% MAXSIZE !

  • 8/14/2019 Implementing the Physical Database.doc

    7/21

    SIZE ! +7MB% MAXSIZE !

  • 8/14/2019 Implementing the Physical Database.doc

    8/21

    -i're A.2S"% Server data&ase o&4ect 'ropi$'s.

    Each data&ase is composed o! all o! these o&4ect 'ropi$'s, tho'h it is $ot ma$datory !or a data&ase to have some o! the o&4ects.Eve$ i! a particlar o&4ect is $ot prese$t #ithi$ a data&ase, the 'ropi$' #ill still &e !o$d.

    o $eed to $o# a little a&ot all o! these o&4ects stored i$ the data&ase, tho'h some are sed more o!te$ tha$ others. $o#i$' a$o&4ect6s prpose cold save yo !rom selecti$' a$ i$accrate a$s#er o$ the eam. +$ particlar, the ta&le o&4ects, their co$te$t, a$dtheir relatio$ships mst &e epertly $o#$.

    Tables

    Each data&ase co$tai$s a $m&er o! ta&les other tha$ those sed to store data. These ta&les store i$!ormatio$ that e$a&les S"%Server to eep trac o! o&4ects a$d procedres #ithi$ the data&ase. The sysob>e*tsa$d sys*omme3tssystem ta&les mai$tai$e$tries co$tai$i$' the o&4ect de!i$itio$s a$d other traci$' i$!ormatio$ !or each o&4ect. @arios other ta&les also eist to mai$tai$i$!ormatio$ a&ot speci!ic o&4ects. -or more i$!ormatio$ re'ardi$' system ta&les, re!er to S"% Server Boos 3$li$e. These ta&les aresed #he$ever S"% Server $eeds o&4ect i$!ormatio$. o shold $ever alter system ta&les directly, &t i$stead allo# S"% Server toma$iplate the e$tries as $eeded.

    7he$ yo6re de!i$i$' ta&les, it is a 'ood idea to have some !orm o! data dictio$ary prepared to help yo mae appropriate choices !ori$dividal properties. * data dictio$ary de!i$es data sa'e a$d is a$ ete$sio$ o! the lo'ical data modeli$'. +$ S"% Server, the termJdata&ase dia'ramJ is sally sed rather tha$ Jdictio$ary,J altho'h a data&ase dia'ram is $ot a complete data dictio$ary i$ the se$seo! docme$tatio$.

    Diagrams

    Dia'rams are o! particlar i$terest to developers &ecase they ca$ provide a visal appeara$ce o! the ta&les #ithi$ the data&ase. *data dictio$ary is a !orm o! docme$tatio$ 'e$erally co$sidered a complete re!ere$ce !or the data it descri&es. The dictio$ary is sallya lot more tha$ 4st a collectio$ o! data eleme$t de!i$itio$s. * complete dictio$ary shold i$clde schema #ith re!ere$ce eys a$d a$e$tity8relatio$ship model o! the data eleme$ts or o&4ects. * psedo data dictio$ary ca$ &e represe$ted si$' the data&ase dia'ram toolprovided #ith S"% Server, as sho#$ i$ -i're A.A.

    There are a lot o! $ice !eatres o! the dia'ram tool that allo# yo to desi'$ a$d e$act cha$'es a'ai$st the data&ase si$' a$attractive, i$titive i$ter!ace. +t is a ha$dy tool !or post8impleme$tatio$ docme$tatio$, as #ell as a trai$i$' assista$t. Docme$ti$' theta&les i$ the system is a$ importa$t aspect o! &si$ess applicatio$ developme$t.

    http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig02.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig03.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig03.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig02.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig03.jpg')
  • 8/14/2019 Implementing the Physical Database.doc

    9/21

    -i're A.A* data&ase dia'ram o! the p&s data&ase.

    %iews

    * viewis a stored ery that is eected a'ai$st the data stored i$ the ta&les. The ta&les o! the data&ase hold the data i$ ro#s a$dcolm$s. @ie#s represe$t the data storedG altho'h they store $o data, they ca$ still &e sed to represe$t the data i$ colm$s a$dro#s.

    Stored Procedures

    *$other eectio$ eleme$t stored #ithi$ the co$tet o! a data&ase is stored procedres. * stored procedureis a set o! T8S"%stateme$ts that ca$ &e saved as a data&ase o&4ect !or !tre a$d repeated eectio$s. 7ith stored procedres, yo ca$ e$a&le a lot o!the developme$t a$d processi$' to &e per!ormed o$ the server, prodci$' mch more e!!icie$t a$d li'ht#ei'ht !ro$t8e$d applicatio$s.

    *$y comma$ds that ca$ &e e$tered via S"% "ery tools ca$ &e i$clded i$ a stored procedre.

    Ma$y system8stored procedres have already &ee$ created a$d are availa&le po$ i$stallatio$ o! S"% Server. Ete$ded storedprocedres, #hich e$a&le D%% !iles to &e accessed !rom the operati$' system, are preesta&lished a$d prese$t i$ the Master data&ase.

    Ete$ded stored procedres, lie ma$y o! the system8stored procedres, are loaded atomatically #he$ yo i$stall S"% Server.Ete$ded stored procedres access D%% !iles stored o$ the machi$e to e$a&le the calli$' o! the !$ctio$s co$tai$ed i$ the D%%s !rom#ithi$ a S"% Server applicatio$. o mi'ht add to this set o! procedres stored i$ the Master data&ase si$' thes1_adde5te3ded1#o* procedre as sho#$ here:

    s1_adde5te3ded1#o* "My&63*t)o3$% "My&63*t)o3Set.DLL$

    Stored procedres a$d vie#s alie ca$ &e sed as part o! a &roader secrity pla$.

    #sers and "olesHsers o! the data&ase either mst &e eplicitly de!i$ed #ithi$ the ?se#sco$tai$er or mst 'ai$ access &y &elo$'i$' to a 'rop thatca$ 'ai$ access to the data&ase. )ole8&ased secrity ca$ also &e impleme$ted at the server, data&ase, or applicatio$ level. *ll o!these aspects mae se o! o&4ects stored i$ the data&ase to help secre the system. Secri$' the data&ase is discssed later i$ the&oo i$ Chapter =, JDesi'$i$' a Data&ase Secrity /la$.J

    http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig03.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig03.jpg')
  • 8/14/2019 Implementing the Physical Database.doc

    10/21

    "ules

    )les are a &ac#ard8compati&ility !eatre that per!orms some o! the same !$ctio$s as C/EC@co$strai$ts. )les are discssed&rie!ly here to e$sre thoro'h covera'e o! ta&le o&4ects. )les, ho#ever, are $ot liely to &e !o$d o$ the eam ecept as a$ i$correcta$s#er. C/EC@co$strai$ts, #hich are discssed later i$ the chapter, are the pre!erred, sta$dard #ay to restrict the vales i$ a colm$.C/EC@co$strai$ts are also more co$cise tha$ rlesG there ca$ &e o$ly o$e rle applied to a colm$, &t mltiple C/EC@co$strai$tsca$ &e applied. )les are similar &t are created as separate o&4ects a$d the$ &o$d to the colm$.

    Defaults

    * DE&A?LTis a$ o&4ect that ca$ &e de!i$ed !or a data&ase a$d is sed &y colm$s o! ta&les #ithi$ the data&ase. * DE&A?LTis sedto provide a vale #he$ $o eplicit vale is 'ive$ po$ i$pt o! data. * DE&A?LTo&4ect mst &e &o$d to each colm$ to #hich it #illapply. +! a DE&A?LTo&4ect is &o$d to a colm$, it is still possi&le to speci!y a di!!ere$t de!alt vale !or that colm$ i$ a a$y 'ive$ta&le. This impleme$ts a de!alt co$strai$t a$d $&i$ds the eisti$' DE&A?LTo&4ect !rom the colm$ &e!ore the $e# de!alt vale isset. +$ this respect the de!alt &ecomes a property o! the colm$ as opposed to a separate o&4ect.

    #ser&Defined Data Types and unctions

    Hser8de!i$ed data types, as eplai$ed i$ Chapter 1, JData&ase Developme$t o$ S"% Server 2000,J are really 4st a$ ete$sio$ o! theS"% Server system data types. Hser8de!i$ed !$ctio$s are de!i$ed &y the developer to &e sed as a codi$' o&4ect to per!orm a tas#ithi$ the &si$ess system. Hser8de!i$ed !$ctio$s are dealt #ith at le$'th i$ Chapter , J/ro'rammi$' Bsi$ess %o'ic.J

    ull&Te't !atalogs

    The remai$i$' o&4ect 'rop is sed to hold -ll8Tet catalo's. These catalo's co$tai$ -ll8Tet i$dees that store i$!ormatio$ a&otsi'$i!ica$t #ords a$d their locatio$ #ithi$ a 'ive$ colm$ o! data #ithi$ the data&ase. -ll8Tet i$dei$', catalo's, a$d eries to'etherallo# yo to search !or E$'lish #ords #ithi$ tet !ields. There are also !((y search capa&ilities that allo# !or searchi$' si$' #ord!orms a$d similar8so$di$' #ords.

    CAUTION

    +$ the past, -ll8Tet i$dei$' has &ee$ a co$sidera&le eam topic, &t it seems to have !alle$ ot o! !avor #ith Microso!t a$d #ill $otliely &e see$ o$ the eam.

    *s yo ca$ see, the maep o! a data&ase i$cldes a lot o! di!!ere$t o&4ects, mch more tha$ 4st ta&les !ll o! data. The maep o! ata&le i$ S"% Server is more tha$ 4st simply data de!i$itio$. * complete ta&le de!i$itio$ i$cldes colm$ descriptio$s, stora'e locatio$,co$strai$ts, relatio$ships #ith other ta&les, i$dees, a$d eys, as #ell as ta&le8level permissio$s a$d tet i$dei$' colm$s.

    (hat)s on the Table

    *!ter the !ile strctre a$d co$te$t o! each !ile has &ee$ determi$ed, the ta&les themselves ca$ &e created a$d assi'$ed to the !iles. +!the prpose o! the ta&le is to hold data that is !ree$tly accessed, the !ile placeme$t o! the ta&le shold tae that i$to co$sideratio$.Ta&les that hold archive data a$d other less !ree$tly accessed data reire less mai$te$a$ce a$d do$6t have to &e as respo$sive toser eries.

    eep i$ mi$d #he$ assi'$i$' o&4ects to !iles that some o&4ects ca$ &e placed a#ay !rom the mai$stream data thro'h the se o!

    !ile'rops. o ca$ select the o&4ect placeme$t !rom Ta&le Desi'$ /roperties i$ the E$terprise Ma$a'er or thro'h the se o! a$ ONclase i$ a CREATEALTERstateme$t. S"% Server e$a&les yo to place the !ollo#i$' ta&le o&4ects:

    Ta&les

    +$dees

    Tet, $tet, or ima'e data

    o #o$6t $ecessarily al#ays &e movi$' o&4ects aro$d. +$ most i$sta$ces, the applicatio$ #o$6t &e lar'e e$o'h to 4sti!y thesemeasres. o $eed to address this sitatio$ o$ly i$ very lar'e data&ase systems.

    Data *lement DefinitionThe i$itial de!i$itio$ o! each colm$ #ithi$ a ta&le co$sists o! a $ame !or the colm$, the type a$d le$'th o! data !or the colm$, a$d a$i$dicator as to #hether the colm$ mst have data or allo# N?LLco$te$t. * $m&er o! additio$al colm$ descriptors ca$ &e i$cldedto de!i$e characteristics o! ho# the colm$ o&tai$s its vale a$d ho# the colm$ is treated #ithi$ the ta&le. * complete list o! pote$tialcolm$ descriptors is 'ive$ here:

  • 8/14/2019 Implementing the Physical Database.doc

    11/21

    Col6m3 Name9Shold &e mea$i$'!l so as to descri&e the colm$ co$te$t.

    Data Ty1e9*$y o$e o! 25 possi&le de!i$itio$s provides the &asis !or the data a colm$ #ill co$tai$. Choices i$cldeseveral possi&ilities !or each data type. Data types are discssed more !lly later i$ this &oo.

    Le3gt29-or ma$y o! the data types, the le$'th is predetermi$ed. o mst, ho#ever, speci!y a le$'th !or character,H$icode 3C/AR, a$d &i$ary data. * le$'th mst also &e speci!ied !or varia&le8le$'th data colm$s. +! a *2a#or a$ 3C/ARdata type is o$ly a si$'le character, $o le$'th has to &e de!i$ed.

    Allow N6lls9o ca$ provide a$ i$dicator !or allo#i$' N?LLco$te$t !or a$y varia&le ecept those assi'$ed as primary

    eys.

    9#)ma#y @ey9E$!orces $ie co$te$t !or a colm$ a$d ca$ &e sed to relate other ta&les. Mst co$tai$ a $ie $o$8N?LLvale.

    Des*#)1t)o39/rovides a$ epla$atio$ o! the colm$ !or docme$tatio$ prposes. This is a$ ete$ded ta&le property.

    Defa6lt al6e9/rovides a vale !or a colm$ #he$ o$e is $ot eplicitly 'ive$ dri$' data e$try. * de!alt o&4ect mst&e created a$d the$ &o$d to a colm$, &t the pre!erred tech$ie is to provide the de!alt de!i$itio$, directly attached to thecolm$ i$ the CREATEALTERta&le de!i$itio$. +t is de!i$ed at the data&ase level a$d ca$ &e tili(ed &y a$y $m&er o!colm$s i$ a data&ase.

    9#e*)s)o39The $m&er o! di'its i$ a $meric colm$.

    S*ale9The $m&er o! di'its to the ri'ht o! a decimal poi$t i$ a $meric colm$.

    Ide3t)ty9+$serts a vale atomatically i$to a colm$, &ased o$ seed a$d i$creme$t de!i$itio$s.

    Ide3t)ty Seed9/rovides the starti$' vale !or a$ Ide3t)tycolm$.

    Ide3t)ty I3*#eme3t9De!i$es ho# a$ Ide3t)ty#ill i$crease or decrease #ith each $e# ro# added to a ta&le.

    Is Row-6)d9+de$ti!ies a colm$ that has &ee$ de!i$ed #ith the ?3);6e Ide3t)f)e#data type as &ei$' the colm$

    to &e sed i$ co$4$ctio$ #ith the RO-?IDCOL!$ctio$ i$ a SELECTlist.

    &o#m6la9/rovides a mea$s o! o&tai$i$' the colm$ co$te$t thro'h the se o! a !$ctio$ or calclatio$.

    Collat)o39Ca$ provide !or a di!!ere$t character set or sort order tha$ other data. Hse #ith etreme catio$, i! at all,&ecase deali$' #ith di!!ere$t character sets impairs !ro$t8e$d developme$t a$d hampers data i$pt a$d alteratio$processes.

    Ma$y characteristics o! colm$ de!i$itio$s #ill have a$ impact o$ the de!i$itio$ o! other colm$s, ta&les, a$d data&ases. -or a morecomplete de!i$itio$ o! a$y o! these properties, co$slt S"% Server Boos 3$li$e.

    +eys to Success

    * ta&le ey is a$ attri&te sed to ide$ti!y a particlar ro# o! the ta&le. Both primary a$d !orei'$ eys are de!i$ed i$ the !orm o! aco$strai$t. These eys #or to'ether to accommodate ta&le relatio$ships. * !orei'$ ey re!ers to the primary ey i$ the pare$t ta&le,!ormi$' a o$e8to8o$e or o$e8to8ma$y relatio$ship. )emem&er !rom the discssio$ o! the lo'ical desi'$ that a ma$y8to8ma$yrelatio$ship is really t#o o$e8to8ma$y relatio$ships si$' a 4oi$i$' ta&le.

    7he$ mltiple ta&les mai$tai$ed i$ a data&ase are related to each other, some measres shold &e tae$ to e$sre that the relia&ilityo! these relatio$ships stays i$tact. To e$!orce re!ere$tial i$te'rity, yo create a relatio$ship &et#ee$ t#o ta&les. This ca$ &e do$ethro'h the data&ase dia'ram !eatre o! the E$terprise Ma$a'er or thro'h the CREATEa$d ALTER TABLET8S"% stateme$ts.Normally, yo relate the re!ere$ci$' or !orei'$ ey o! o$e ta&le to the primary ey or other $ie vale o! a seco$d ta&le.

    PRIMARY !Y Constraint

    * 9RIMAR: @E:co$strai$t e$!orces e$tity i$te'rity i$ that it does $ot permit a$y t#o ro#s i$ a ta&le to have the same ey vale. Thise$a&les each ro# to &e $iely de!i$ed i$ its o#$ ri'ht. *ltho'h a primary ey shold &e created #he$ a ta&le is i$itially created, itca$ &e added or cha$'ed at a$y time a!ter creatio$. The primary ey ca$ &e added po$ creatio$ o! the ta&le as 'ive$ here:

    CREATE TABLE Ot2e#A6t2o#s a6_)d )d NOT N?LL

  • 8/14/2019 Implementing the Physical Database.doc

    12/21

    CONSTRAINT ?9@CL_ot2a6)3d 9RIMAR: @E: CL?STERED%a6_l3ame =a#*2a# 70 NOT N?LL %a6_f3ame =a#*2a#

  • 8/14/2019 Implementing the Physical Database.doc

    13/21

    The cascadi$' actio$s !eatre is a $e# !eatre, a$d yo ca$ epect that somethi$' a&ot it #ill &e ased o$ the eam. *lso &eprepared !or the eam &y $o#i$' all the reslts a$d implicatio$s o! cascadi$' actio$s. -or eample, yo mi'ht &e ased #hat occrs#he$ a record co$tai$ed i$ the pare$t ta&le is deleted or has its ey vale cha$'ed.

    +$ a cascadi$' pdate, #he$ yo cha$'e the vale o! a ey i$ a sitatio$ i$ #hich a !orei'$ ey i$ a$other ta&le re!ere$ces the eyvale, those cha$'ed vales are re!lected &ac to the other ta&les. * similar thi$' happe$s #ith a delete operatio$: +! a record isdeleted, all s&sidiary records i$ other ta&les are also deleted. -or eample, i! a$ i$voice record is deleted !rom a$ i$voice ta&le thathas i$voice details stored i$ a$other ta&le a$d re!ere$ced &y a !orei'$ ey, the$ the details #old also &e removed.

    * series o! cascadi$' actio$s cold easily reslt !rom the pdate or deletio$ o! importa$t eys. -or eample, the deletio$ o! a cstomer

    cold case the deletio$ o! all that cstomer6s orders, #hich cold case the deletio$ o! all the cstomer6s i$voices, #hich i$ tr$ coldcase the deletio$ o! all the cstomer6s i$voice details. -or this reaso$, care!l system desi'$ is importa$t, a$d the pote$tial archivi$'o! data thro'h the se o! tri''ers shold &e co$sidered.

    +$ the case o! mltiple cascadi$' actio$s, all the tri''ers to &e !ired &y the e!!ects o! the ori'i$al deletio$ !ire !irst. A&TERtri''ers the$!ire o$ the ori'i$al ta&le, a$d the$ the A&TERtri''ers i$ the ta&le chai$ s&see$tly !ire.

    ,aintaining -rder with Inde'es

    /tti$' the data i$to see$ce to accommodate ic retrieval, a$d at the same time provide mea$i$'!l a$d sa&le otpt to a$applicatio$, sally reires that a variety o! i$dees &e de!i$ed. * clstered i$de provides the physical order o! the data &ei$' stored,#hereas a $o$clstered i$de provides a$ ordered list #ith poi$ters to the physical locatio$ o! the data.

    +$dei$' is most easily de!i$ed a$d $derstood i! yo compare the data a$d i$de stora'e o! a data&ase to that o! a &oo. +$ a &oothe data itsel! is placed o$to the pa'es i$ a see$ce that is mea$i$'!l i! yo read the &oo see$tially !rom cover to cover. *$ i$deat the &ac o! the &oo e$a&les yo to read the data ra$domly. o ca$ locate a topic &y looi$' thro'h a list o! topics that isaccompa$ied &y a physical pa'e re!ere$ce to the place #here the topic ca$ &e !o$d. To read a si$'le topic, yo $eed $ot simthro'h the e$tire &oo.

    +$ a similar ma$$er, data i$ a data&ase ca$ &e ha$dled ra$domly or i$ see$ce. * si$'le record ca$ &e located i$ the data&ase &ylooi$' it p i$ the i$de, rather tha$ readi$' thro'h all the rest o! the data. Co$versely, i! a report is to &e 'e$erated !rom all the datai$ a data&ase, the data itsel! ca$ &e read see$tially i$ its e$tirety.

    +$de stora'e i$ S"% Server has a B8tree strctred stora'e. The i$dees are mai$tai$ed i$

  • 8/14/2019 Implementing the Physical Database.doc

    14/21

    CREATE INDEX IX9#od6*tItemON 9#od6*tO#de#L)3e O#de#Mate@ey% 9#od6*tL)3e@ey0IT/ &ILL&ACTOR ! G,

    The t#o di!!ere$t or'a$i(atio$s o! i$dees, clustereda$d nonclustered, provide !or the orderi$' o! data either thro'h physicallyrearra$'i$' the data as i$ a clstered i$de or thro'h the se o! data poi$ters as i$ a $o$clstered i$de. +! the or'a$i(atio$ is $otspeci!ied, as i$ the previos eample, $o$clstered #ill &e de!alted to.

    Inde%in& Throu&h Reorderin&Clustered

    The selectio$ o! the appropriate colm$s o$ #hich to &ase a clstered i$de is importa$t !or several reaso$s. *s previoslyme$tio$ed, a clstered i$de represe$ts the order i$ #hich the data is physically stored o$ the dis. -or this reaso$, yo ca$ de!i$eo$ly a si$'le clstered i$de !or a$y ta&le. +! yo choose $ot to se a clstered i$de i$ a ta&le, the data o$ the dis #ill &e stored i$ aheap. * clstered i$de, i! prese$t, has clsteri$' eys that are sed &y all $o$clstered i$dees to determi$e the physical locatio$ o!the data.

    The &asis !or the i$de sally is determi$ed &y the order i$ #hich the ma4ority o! applicatio$s a$d eries #a$t their otpt. Theclstered i$de vales are also prese$t i$ other i$dees, a$d the si(e o! the de!i$ed i$de shold &e ept as small as possi&le. 7he$yo select a clsteri$' ey, try to tili(e a $meric data type &ecase character types case i$de stora'e to occpy mch morespace.

    *l#ays de!i$e a clstered i$de !irst &e!ore yo de!i$e a$y o! the $o$clstered i$dees. +! yo do these tass i$ reverse order, all$o$clstered i$dees re&ild themselves po$ creatio$ o! the clstered i$de.

    Inde%in& Throu&h (ata PointersNonclustered

    No$clstered i$dees provide a mea$s o! retrievi$' the data !rom the data&ase i$ a$ order other tha$ that i$ #hich the data isphysically stored. The o$ly alter$ative to the se o! these i$dees #old &e provisio$s !or a sort operatio$ that #old place $deoverhead o$ the clie$t system a$d mi'ht $ot prodce the desired respo$se times. * data sort impleme$tatio$ is sally per!ormed o$ly!or o$e8time operatio$s or !or applicatio$s that #ill have very limited sa'e.

    *ltho'h the creatio$ o! i$dees saves time a$d resorces i$ a lot o! cases, avoid the creatio$ o! i$dees that #ill rarely &e tili(ed.Each time a record is added to a ta&le, all i$dees i$ the ta&le mst &e pdated, a$d this mi'ht also case $de system overhead.-or that reaso$, care!l pla$$i$' o! i$de sa'e is $ecessary.

    One o) a indUnique Inde%in&

    7he$ i$dees are created, it is importa$t to 'ara$tee that each vale is disti$ctive. This is particlarly importa$t !or a primary ey.S"% Server atomatically applies a $ie i$de to a primary ey to e$sre that each ey vale $iely de!i$es a ro# i$ the ta&le.o mi'ht #a$t to create additio$al $ie i$dees !or colm$s that are $ot 'oi$' to &e de!i$ed as the primary ey.

    "oom for Additions

    -ill !actor is the perce$t at #hich S"% Server !ills lea!8level pa'es po$ creatio$ o! i$dees. /rovisio$ !or empty pa'es e$a&les theserver to i$sert additio$al ro#s #ithot per!ormi$' a pa'e8split operatio$. * pa'e split occrs #he$ a $e# ro# is i$serted i$to a ta&lethat has $o empty space !or its placeme$t. *s the stora'e pa'es !ill, pa'e splits occr, #hich ca$ hamper per!orma$ce a$d i$crease!ra'me$tatio$.

    o #ill $ormally !i$d that eries the readi$' o! eisti$' data ot#ei'h data pdates &y a s&sta$tial mar'i$. /rovidi$' the etraroom slo#s do#$ the ery process. There!ore, yo mi'ht $ot #a$t to ad4st the !ill !actor vale at all i$ static systems i$ #hich thereare smaller $m&ers o! additio$s.

    Eally, setti$' the !ill !actor too lo# hampers read per!orma$ce &ecase the server mst $e'otiate a series o! empty pa'es to actally!etch the desired data. +t is &e$e!icial to speci!y a !ill !actor #he$ yo create a$ i$de o$ a ta&le that already has data a$d #ill have ahi'h volme o! i$serts. +! yo do $ot speci!y this setti$' #he$ creati$' a$ i$de, the server de!alt !ill !actor setti$' is chose$. The !ill!actor !or the server is a co$!i'ratio$ optio$ set thro'h the E$terprise Ma$a'er or the s1_*o3f)g6#estored procedre.

    The perce$ta'e vale !or the !ill !actor is $ot mai$tai$ed over timeG it applies o$ly at the time o! creatio$. There!ore, i! i$serts i$to ata&le occr !ree$tly, it6s importa$t to tae mai$te$a$ce measres !or re&ildi$' the i$dees to e$sre that the empty space is pt&ac i$ place. * speci!ic i$de ca$ &e re&ilt si$' the CREATE INDEXT8S"% comma$d #ith the DRO9 EXISTIN-optio$.+$dees ca$ also &e de!ra'me$ted si$' the DBCC INDEXDE&RA-comma$d, #hich also reapplies the !ill !actor.

    The /ad +$de setti$' is closely related to the setti$' !or !ill !actor to allo# space to &e le!t i$ $o$8lea! levels. /ad +$de ca$$ot &especi!ied &y itsel! a$d ca$ &e sed o$ly i! yo spply a !ill !actor. o do $ot provide a vale !or this setti$'G it matches the setti$' 'ive$!or the !ill !actor.

    Data *ntry #sing Defaults

  • 8/14/2019 Implementing the Physical Database.doc

    15/21

    * de!alt is sed to provide a vale !or a colm$ to mi$imi(e data e$try e!!orts or to provide a$ e$try #he$ the data is $ot $o#$. *de!alt provides a vale !or the colm$ as a &asis !or i$itial i$pt. *$y data that is e$tered !or the colm$ overrides the de!alt e$try.o ca$ apply a de!alt de!i$itio$ to a colm$ directly si$' the CREATEor ALTER TABLEstateme$t or thro'h the Desi'$ Ta&leoptio$ !rom #ithi$ the E$terprise Ma$a'er. o ca$ also create a de!alt as its o#$ o&4ect a$d the$ &i$d it to o$e or more colm$s.

    * de!alt de!i$itio$ that is provided as part o! a ta&le de!i$itio$ is a sta$dard a$d pre!erred method o! impleme$ti$' de!alt e$tries. Theadva$ta'es o! this tech$ie are that the de!alt is dropped #he$ the ta&le is dropped a$d that the de!i$itio$ is stored #ithi$ the ta&leitsel!. * de!alt o&4ect mst &e created a$d &o$d to the colm$ i$ a t#o8step operatio$. To create a$d &i$d a de!alt o&4ect, se the!ollo#i$' code:

    CREATE DE&A?LT StateDefa6lt AS "IN$ s1_b)3defa6lt StateDefa6lt% "*6stome#s.state$To *#eate a defa6lt w)t2)3 a table def)3)t)o3% 6se t2e follow)3g'CREATE TABLE Sam1leDefa6lt Sam1leID small)3t NOT N?LL CONSTRAINT ?9@CL_Sam1leID 9RIMAR: @E: CL?STERED% C)ty =a#*2a#,70 DE&A?LT "oodsto*H$0% State *2a#

  • 8/14/2019 Implementing the Physical Database.doc

    16/21

    O#de#Mat*2@ey B)gI3t%9#od6*tO#de#ed C2a#0%

    FtyO#de#ed B)gI3t CONSTRAINT O=e#,7 C/EC@ FtyO#de#ed J ,70% O#de#Date DateT)me% Re;6)#edDate DateT)me% CONSTRAINT C@_Date C/EC@ Re;6)#edDate J O#de#Date00

    Hsally a si$'le ta&le de!i$itio$ #old provide clases !or ey de!i$itio$, i$dei$', a$d other eleme$ts that have &ee$ le!t ot o! theprevios de!i$itio$ to !ocs i$ more closely o$ the se o! CEC co$strai$ts.

    *s yo ca$ see, co$strai$ts come i$ all shapes a$d si(es, co$trolli$' ta&le co$te$t, i$ter8ta&le relatio$ships, a$d validity o! data.*ltho'h #e have discssed ma$y o&4ects, there are a !e# loose e$ds to tie p i$ order to 'et a !ll perspective o$ o&4ects.

    -ther /its and Pieces

    There are ma$y di!!ere$t o&4ects #ithi$ a data&ase a$d srro$di$' the ta&le co$te$t. * !e# o&4ects le!t to discss are ratherspeciali(ed i$ their se a$d i$ #here they are applied. /ermissio$s #hich #e #ill leave $til Chapter = are a #ide array o! ri'hts a$dprivile'es that are prese$t at several levels, !rom the server to the data&ase to the ta&le, all the #ay do#$ to a$ i$dividal colm$.There are also paca'es that co$tai$ de!i$itio$s o! procedres sed &y DTS to 'et data !rom o$e place to a$other DTS paca'es arediscssed i$ Chapter 5, J)etrievi$' a$d Modi!yi$' DataJ.

    Alerts, operators, a$djobs#or to'ether to aid i$ admi$istratio$ over the server &y allo#i$' !or the modi!icatio$ o! tass a$d i$!ormi$'i$dividals o! importa$t eve$ts o$ the server. These, alo$' #ith articles, p&licatio$s, a$d s&scriptio$s, are de!i$ed i$ the $etchapter, J*dva$ced /hysical Data&ase +mpleme$tatio$.J The o$ly o&4ect le!t $de!i$ed !rom a data perspective is tri''ers.

    Trigger #tili0ation

    Tri''ers are lie stored procedres i$ that they co$tai$ a set o! T8S"% stateme$ts saved !or !tre eectio$. The &i' di!!ere$ce is that,$lie stored procedres, tri''ers are eected atomatically &ased o$ data activity i$ a ta&le. * tri''er may !ire &ased o$ ?9DATE,INSERT, or DELETEoperatio$s.

    +$ S"% Server 2000, tri''ers ca$ &e !ired aftera$ operatio$ completes S"% Server de!alt or instead ofthe tri''eri$' operatio$. *$A&TERtri''er ca$ &e sed to archive data #he$ it is deleted, to se$d a $oti!icatio$ that the $e# data has &ee$ added or cha$'ed, orto i$itiate a$y other process yo mi'ht #a$t to atomate &ased o$ data activity. *$ INSTEAD O&tri''er ca$ &e sed to per!orm more

    adva$ced activities sch as adva$ced data checi$', to e$a&le pdates i$ a vie# to occr across mltiple ta&les, a$d to per!ormma$y other !$ctio$s that mi'ht &e $ecessary i$ place o! a tri''eri$' activity.

    Tri''ers represe$t a mecha$ism i$ #hich code ca$ &e eected &ased o$ activity i$ the data. Tri''ers are epa$ded o$ a$d !llyillstrated i$ Chapter .

    Troubleshooting ailed -b1ect !reation

    Tro&leshooti$' is certai$ly a &road topic i$ the real developme$t #orld, a$d certai$ly o$ all Microso!t eams. +$ this chapter the !ocs!or tro&leshooti$' is o$ the i$teractio$s #ith o&4ects a$d the server, as #ell as applicatio$ setti$'s that are reired !or a$ o&4ect to &ecreated a$d sed. 3$ the eam tro&leshooti$' #ill &e approached !rom a #ide variety o! a$'les. +$ the Jreal #orldJ it is 'ood practiceto al#ays vie# a procedre !rom a pro&lem8solvi$' perspective. *l#ays &e ready to as yorsel!, J7hat cold 'o #ro$'KJ a$d J7hatca$ &e do$e to resolve the pro&lemKJ

    Most pro&lems associated #ith creati$' a$dor accessi$' o&4ects ca$ &e resolved thro'h setti$' appropriate o&4ect accesspermissio$s. o#ever, other eleme$ts that ca$ hamper the creatio$ or se o! o&4ects i$clde &t are $ot limited to the !ollo#i$':

    Bacp a$d restore operatio$s

    3ther sers6 operatio$s loci$' parts o! the system

    ard#are or resorce pro&lems

    Net#or co$$ectivity

    Co$!i'ratio$ setti$'s

    3perati$' system

    Metadata corrptio$

  • 8/14/2019 Implementing the Physical Database.doc

    17/21

    * 'ood starti$' poi$t !rom #hich to resolve most pro&lems is the #ealth o! !eed&ac S"% Server 'ives i$ the !orm o! the 3S *pplicatio$Eve$t %o', S"% Server %o's, a$d the Crre$t *ctivity 7i$do#, as #ell as the permissio$ properties o! the sers, roles, a$d o&4ects.

    To create a data&ase, yo $eed to &e a mem&er o! System *dmi$istrators or Data&ase Creators server roles or have the CreateData&ase permissio$. To create o&4ects #ithi$ a data&ase, yo mst &e a mem&er o! db_ow3e#or db_ddladm)3data&ase rolesor have the speci!ic permissio$ to create the o&4ect as 'ive$ &y stateme$t8level permissio$s. Stateme$t8level permissio$s ca$ &e !o$do$ the /ermissio$s ta& o! the data&ase /roperties dialo' &o.

    *s data&ases a$d their o&4ects are created, the system ses the de!alt !ile'rop !or the physical stora'e o! the eleme$t. +t is a 'oodpractice to create a stora'e 'rop !or ser o&4ects a$d mae that the de!alt !ile'rop. This #ay, as the ser creates o&4ects, those

    o&4ects do$6t compete !or stora'e #ith other data.

    +! a ser lacs the permissio$ to create or alter a$ o&4ect, a$ alter$ative is availa&le that 'ra$ts the ser creatio$ permissio$ #ithot'ivi$' the ser too mch co$trol over the e$viro$me$t. *$ *pplicatio$ role that has permissio$ to #or #ith o&4ects i$ this ma$$er ca$&e assi'$ed to a stored procedre that creates the o&4ects !or the ser. 7he$ the ser eectes the procedre, o&4ects ca$ &e createdor altered i$ a co$trolled ma$$er.

    *'am Prep Questions

    1. *s a developer !or a lar'e healthcare provider, yo are assi'$ed the tas o! developi$' a process !or pdati$' a patie$tdata&ase. 7he$ a patie$t is tra$s!erred !rom o$e !loor to a$other, a$ i$ter$al ide$ti!ier, C6##e3tRoomID, #hich is sed asthe primary ey, $eeds to &e altered #hile the ori'i$al ey, Adm)tta3*eRoomID, is mai$tai$ed. +! a patie$t is moved moretha$ o$ce, o$ly the ori'i$al ey a$d the crre$t ey $eed to &e mai$tai$ed. Several $derlyi$' ta&les have &ee$ co$!i'red

    !or re!ere$tial i$te'rity a'ai$st the patie$t ta&le. These $derlyi$' ta&les mst cha$'e i$ a$ appropriate ma$$er to match #itho$e or the other o! the room eys i$ the patie$t ta&le. These relatio$ships #ill &e altered &ased o$ di!!ere$t sitatio$s i$ otherta&les.-i're A.5illstrates the 9at)e3tT#a*He#ta&le desi'$ ehi&it. 7hat method #old yo se to accommodate thepdateK

    -i're A.5The /atie$tTracer ta&le desi'$ ehi&it.

    *. Hse the Cascade Hpdate )elated -ields optio$ to have cha$'es i$ the primary ey atomatically pdate the eys i$all re!ere$ced ta&les.

    B. Hse a$ i$deed vie# to e$a&le the ser to mae cha$'es to mltiple ta&les co$crre$tly.

    C. Disa&le the E$!orce )elatio$ship !or +$serts a$d Deletes optio$ to e$a&le a$ A&TER TRI--ERto ha$dle the$ecessary cha$'es.

    D.De!i$e a$

    INSTEAD O& ?9DATE TRI--ERto per!orm the $ecessary pdates to all related ta&les.

    Ans*er: (.The INSTEAD O&tri''er #as desi'$ed speci!ically !or this type o! sitatio$ a$d also to ha$dle complicatedpdates i$ #hich colm$s are de!i$ed as T)mestam1, Cal*6lated, or Ide3t)ty. Cascade operatio$s arei$appropriate &ecase the pdated ey is $ot al#ays stored. +$deed vie#s &y themselves do $ot allo# !or the type o!alteratio$ desired a$d #old have to &e compleme$ted #ith the actio$s o! a tri''er. Disa&li$' re!ere$tial i$te'rity is a poorsoltio$ to a$y pro&lem, especially co$sideri$' the medical $atre o! this applicatio$ a$d the possi&le rami!icatio$s. -or morei$!ormatio$, see the earlier sectio$ JTri''er Htili(atio$.J

    2. * lar'e or'a$i(atio$ $eeds to mai$tai$ ima'e data o$ a data&ase server. The data is sca$$ed i$ !rom docme$ts received!rom the !ederal 'over$me$t. Hpdates to the ima'es are i$!ree$t. 7he$ a cha$'e occrs, sally the old ro# o! data isarchived ot o! the system a$d the $e# docme$t taes its place. 3ther colm$ i$!ormatio$ that co$tai$s ey ide$ti!iers a&otthe $atre o! the docme$t is !ree$tly eried &y a$ 3%*/ system. Statistical i$!ormatio$ o$ ho# the data #as eried isalso stored i$ additio$al colm$s. The actal docme$t itsel! is rarely $eeded ecept i$ processes that pri$t the ima'e. 7hich

    o! the !ollo#i$' represe$ts a$ appropriate stora'e co$!i'ratio$K*. /lace the ima'e data i$to a !ile'rop o! its o#$, &t o$ the same volme as the remai$der o! the data. /lace the lo'

    o$to a volme o! its o#$.

    B. /lace all the data o$to o$e volme i$ a si$'le !ile. Co$!i're the volme as a )*+D parity set a$d place the lo' i$to avolme o! its o#$.

    http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig05.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig05.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig05.jpg')http://www.informit.com/articles/article.asp?p=415181&seqNum=6http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig05.jpg')http://popup%28%27/content/images/chap3_0789731061/elementLinks/03fig05.jpg')http://www.informit.com/articles/article.asp?p=415181&seqNum=6
  • 8/14/2019 Implementing the Physical Database.doc

    18/21

    C. /lace the ima'e o$to o$e volme i$ a !ile o! its o#$ a$d place the data a$d lo' !iles to'ether o$ a seco$d volme.

    D. /lace the ima'e i$to a separate !ile'rop #ith the lo' o$ o$e volme a$d the remai$der o! the data o$ a seco$dvolme.

    Ans*er: (.Becase the ima'e data #ill seldom &e accessed, it maes se$se to 'et the remai$der o! the data a#ay !rom theima'es #hile movi$' the lo' a#ay !rom the data. This #ill help to improve per!orma$ce #hile providi$' optimm recovera&ilityi$ the eve$t o! a !ailre. -or more i$!ormatio$, see JThe -ile System.J

    A. *$ +$ter$et compa$y sells otdoor hard#are o$li$e to more tha$ 100,000 clie$ts i$ varios areas o! the 'lo&e. Servici$' the#e&site is a S"% Server #hose per!orma$ce is &arely adeate to meet the $eeds o! the site. o #old lie to apply a&si$ess rle to the eisti$' system that #ill limit the otsta$di$' &ala$ce o! each cstomer. The otsta$di$' &ala$ce ismai$tai$ed as a de$ormali(ed colm$ #ithi$ the cstomer ta&le. 3rders are collected i$ a seco$d ta&le co$tai$i$' a tri''erthat pdates the cstomer &ala$ce &ased o$ INSERT, ?9DATE, a$d DELETEactivity. Hp to this poi$t, care has &ee$ tae$to remove a$y data !rom the ta&le i! the clie$t &ala$ce is too hi'h, so all data shold meet the reireme$ts o! yor $e#process. o# #old yo apply the $e# data checK

    *. Modi!y the eisti$' tri''er so that a$ order that allo#s the &ala$ce to eceed the limit is $ot permitted.

    B. Create a chec co$strai$t #ith the No Chec optio$ e$a&led o$ the cstomer ta&le, so that a$y i$appropriate order isre!sed.

    C. Create a rle that does$Lt permit a$ order that eceeds the limit a$d &i$d the rle to the 3rders ta&le.

    D. Create a $e# tri''er o$ the 3rders ta&le that re!ses a$ order that cases the &ala$ce to eceed the maimm.*pply the $e# tri''er to o$ly INSERTa$d ?9DATEoperatio$s.

    Ans*er: A.Becase a tri''er is already i$ place, it ca$ easily &e altered to per!orm the additio$al data chec. * rle ca$$otprovide the reired !$ctio$ality &ecase yo ca$$ot compare the data. The C/EC@co$strai$t may &e a via&le soltio$ &tyo #old have to alter the tri''er to chec !or a$ error a$d provide !or $ested operatio$s. The $m&er o! tri''ers !iri$' shold&e ept to a mi$imm. To accommodate additio$al tri''ers, yo #old have to chec the order i$ #hich they are &ei$' !ireda$d a'ai$ set properties o! the server a$d data&ase accordi$'ly. -or more i$!ormatio$, see J Tri''er Htili(atio$.J

    ;. *$ eisti$' sales catalo' data&ase strctre eists o$ a system #ithi$ yor compa$y. The compa$y sells i$ve$tory !rom asi$'le #arehose locatio$ that is across to#$ !rom #here the compter systems are located. The prodct ta&le has &ee$created #ith a $o$8clstered i$de &ased o$ the prodct +D, #hich is also the /rimary ey. No$8clstered i$dees eist o$ theprodct cate'ory colm$ a$d also the stora'e locatio$ colm$. Most o! the reporti$' do$e is ordered &y prodct cate'ory.

    o# #old yo cha$'e the eisti$' i$de strctreK*. Cha$'e the de!i$itio$ o! the /rimary ey so that it is a clstered i$de.

    B. Create a $e# clstered i$de &ased o$ the com&i$atio$ o! stora'e locatio$ a$d prodct cate'ory.

    C. Cha$'e the de!i$itio$ o! the prodct cate'ory so that it is a clstered i$de.

    D. Cha$'e the de!i$itio$ o! the stora'e locatio$ so that it is a clstered i$de.

    Ans*er: (.Becase the ma4ority o! the reporti$' is 'oi$' to &e per!ormed si$' the stora'e locatio$, it #old &e the lielyca$didate. The clstered i$de represe$ts the physical order o! the data a$d #old mi$imi(e sorti$' operatio$s #he$ derivi$'the otpt. -or more i$!ormatio$, see JMai$tai$i$' 3rder #ith +$dees.J

    5. o are desi'$i$' a$ applicatio$ that #ill provide data e$try clers the capa&ility o! pdati$' the data i$ several ta&les. o#old lie to ease e$try a$d provide commo$ i$pt so the clers $eed $ot e$ter data i$to all !ields or e$ter red$da$t vales.7hat types o! tech$olo'ies cold yo se to mi$imi(e the amo$t o! i$pt $eededK Select all that apply.

    *. -orei'$ ey

    B. Cascadi$' pdate

    C. Ide3t)tycolm$

    D. De!alt

    E. N?LL

    -. /rimary ey

    . H$ie i$de

    http://www.informit.com/articles/article.asp?p=415181&seqNum=3http://www.informit.com/articles/article.asp?p=415181&seqNum=3http://www.informit.com/articles/article.asp?p=415181&seqNum=6http://www.informit.com/articles/article.asp?p=415181&seqNum=6http://www.informit.com/articles/article.asp?p=415181&seqNum=5#maintaininghttp://www.informit.com/articles/article.asp?p=415181&seqNum=5#maintaininghttp://www.informit.com/articles/article.asp?p=415181&seqNum=3http://www.informit.com/articles/article.asp?p=415181&seqNum=6http://www.informit.com/articles/article.asp?p=415181&seqNum=5#maintaining
  • 8/14/2019 Implementing the Physical Database.doc

    19/21

    Ans*er: +, C, (, !.*ll these optio$s have activities that provide or alter data so that it does $ot have to &e per!ormed as a$e$try operatio$. +$ the case o! N?LL, data $eed $ot &e provided, possi&ly &ecase the colm$ co$tai$s $o$8criticali$!ormatio$. -or more i$!ormatio$, see Jeys to Sccess.J

    . * data&ase that yo are #ori$' o$ is eperie$ci$' redced per!orma$ce. The data&ase is sed almost eclsively !orreporti$', #ith a lar'e $m&er o! i$serts occrri$' o$ a re'lar &asis. Data is cycled ot o! the system !or times a year aspart o! arter8e$di$' procedres. +t is al#ays importa$t to &e a&le to attai$ a poi$t8i$8time restoratio$ process. o #old lieto mi$imi(e the mai$te$a$ce $eeded to accommodate i$creases a$d decreases i$ !ile stora'e space. 7hich optio$ #oldassist the most i$ accomplishi$' the tasK

    *. SIM9LE RECOER:

    B. A?TOS/RIN@

    C. MAXSIZE

    D. A?TO-RO

    E. COLLATE

    Ans*er: (.Hse A?TO-ROto set the system so that the !iles #ill 'ro# as $eeded !or the additio$ o! $e# data. o may#a$t to per!orm a pla$$ed shri$a'e o! the data&ase as part o! the arter8e$di$' process a$d save o$ overhead &y leavi$'

    the A?TOS/RIN@optio$ tr$ed o!!. -or more i$!ormatio$, see JCreati$' -iles a$d -ile'rops.J

    ?. o are the admi$istrator o! a S"% Server 2000 compter. The server co$tai$s a data&ase $amed +$ve$tory. Hsers reportthat several stora'e locatio$s i$ the ?3)tsSto#ed!ield co$tai$ $e'ative $m&ers. o eami$e the data&aseLs ta&lestrctre. o correct all the $e'ative $m&ers i$ the ta&le. o mst preve$t the data&ase !rom stori$' $e'ative $m&ers.o also #a$t to mi$imi(e se o! server resorces a$d physical +3. 7hich stateme$t shold yo eecteK

    A. ALTER TABLE dbo.Sto#ageLo*at)o3sB. ADD CONSTRAINTC@_Sto#ageLo*at)o3s_C. ?3)tsSto#edC/EC@ ?3)tsSto#ed J! 70D. CREATE TRI--ER C@_?3)tsSto#ed O3 _E. Sto#ageLo*at)o3s &OR INSERT% ?9DATE AS&. I& INSERTED.?3)tsSto#ed 7 ROLLBAC@ TRAN-. CREATER?LE C@_?3)tsSto#ed As

    /. ?3)ts J! 7I. -OP. s1_b)3d#6le QC@_?3)tsSto#edQQ_@. Sto#ageLo*at)o3s.?3)tsSto#edQL. -OM. CREATE 9ROC ?1date?3)tsSto#edSto#ageLo*at)o3ID_N. )3t% ?3)tsSto#ed b)g)3t0 ASO. I& ?3)tsSto#ed 79. RAISERROR ,77% +G0F. ELSER. ?9DATE Sto#ageLo*at)o3sS. SET ?3)tsSto#ed ! ?3)tsSto#edT. /ERE Sto#ageLo*at)o3ID ! Sto#ageLo*at)o3ID

    Ans*er: A.o $eed to add a co$strai$t to preve$t $e'ative data e$try. The &est method o! impleme$ti$' this !$ctio$ality isa co$strai$t. * tri''er has too mch overhead a$d the R?LEis $ot accrately impleme$ted. * procedre cold ha$dle theprocess &t is $ormally sed o$ly !or processes reiri$' more comple lo'ic. -or more i$!ormatio$, see J 7hatLs o$ theTa&le.J

  • 8/14/2019 Implementing the Physical Database.doc

    20/21

    E. If Not E5)sts Sele*t ?9C om 9a#ts&. 2e#e 9a#ts.?9C ! )3se#ted.?9C0-. BE-IN/. ROLLBAC@ TRANI. ENDP. CREATE TRI--ER ?9CRI O3 9a#ts &OR INSERT% ?9DATE As@. If Not E5)sts Sele*t ?9C om 9a#tsL. 2e#e O#de#Deta)ls.?9C ! )3se#ted.?9C0M. BE-INN. ROLLBAC@ TRAN

    O. END9. ALTER TABLE dbo.O#de#Deta)lsF. ADD CONSTRAINT&@_O#de#Deta)ls_9a#ts _R. &OREI-N @E:?9C0RE&ERENCES dbo.9a#ts?9C0S. ALTER TABLE dbo.9a#tsT. ADD CONSTRAINT&@_9a#ts_O#de#Deta)ls?. &OREI-N @E: ?9C0RE&ERENCES dbo.9a#ts?9C0

    Ans*er: A, !.The ?NIF?Eco$strai$t o$ the 9a#tsta&le H/C colm$ is reired !irst so that the &OREI-N @E:co$strai$t ca$ &e applied !rom the O#de#Deta)ls.?9C colm$ re!ere$ci$' 9a#ts.?9C. This achieves the re!ere$tiali$te'rity reireme$t. +t also redces +3 reired dri$' 4oi$s &et#ee$ 9a#tsa$d O#de#Deta)ls, #hich mae se o! the&OREI-N @E:co$strai$t de!i$ed. -or more i$!ormatio$, see J&OREI-N @E: Co$strai$t.J

    =. o are the data&ase developer !or a leasi$' compa$y. or data&ase i$cldes a ta&le that is de!i$ed as sho#$ here:+7. CREATE TABLE Lease++. Id I3t IDENTIT: NOT N?LL+

  • 8/14/2019 Implementing the Physical Database.doc

    21/21

    1