您好,欢迎访问三七文档
DatabaseSystemConcepts,5thEd.©Silberschatz,KorthandSudarshanSee©Silberschatz,KorthandSudarshan7.2DatabaseSystemConcepts-5thEdition,July28,2005.Chapter7:RelationalDatabaseDesignFeaturesofGoodRelationalDesignAtomicDomainsandFirstNormalFormDecompositionUsingFunctionalDependenciesFunctionalDependencyTheoryAlgorithmsforFunctionalDependenciesDecompositionUsingMultivaluedDependenciesMoreNormalFormDatabase-DesignProcessModelingTemporalData©Silberschatz,KorthandSudarshan7.3DatabaseSystemConcepts-5thEdition,July28,2005.TheBankingSchemabranch=(branch_name,branch_city,assets)customer=(customer_id,customer_name,customer_street,customer_city)loan=(loan_number,amount)account=(account_number,balance)employee=(employee_id.employee_name,telephone_number,start_date)dependent_name=(employee_id,dname)account_branch=(account_number,branch_name)loan_branch=(loan_number,branch_name)borrower=(customer_id,loan_number)depositor=(customer_id,account_number)cust_banker=(customer_id,employee_id,type)works_for=(worker_employee_id,manager_employee_id)payment=(loan_number,payment_number,payment_date,payment_amount)savings_account=(account_number,interest_rate)checking_account=(account_number,overdraft_amount)©Silberschatz,KorthandSudarshan7.4DatabaseSystemConcepts-5thEdition,July28,2005.CombineSchemas?Supposewecombineborrowerandloantogetbor_loan=(customer_id,loan_number,amount)Resultispossiblerepetitionofinformation(L-100inexamplebelow)©Silberschatz,KorthandSudarshan7.5DatabaseSystemConcepts-5thEdition,July28,2005.ACombinedSchemaWithoutRepetitionConsidercombiningloan_branchandloanloan_amt_br=(loan_number,amount,branch_name)Norepetition(assuggestedbyexamplebelow)©Silberschatz,KorthandSudarshan7.6DatabaseSystemConcepts-5thEdition,July28,2005.WhatAboutSmallerSchemas?Supposewehadstartedwithbor_loan.Howwouldweknowtosplitup(decompose)itintoborrowerandloan?Writearule“iftherewereaschema(loan_number,amount),thenloan_numberwouldbeacandidatekey”Denoteasafunctionaldependency:loan_numberamountInbor_loan,becauseloan_numberisnotacandidatekey,theamountofaloanmayhavetoberepeated.Thisindicatestheneedtodecomposebor_loan.Notalldecompositionsaregood.Supposewedecomposeemployeeintoemployee1=(employee_id,employee_name)employee2=(employee_name,telephone_number,start_date)Thenextslideshowshowweloseinformation--wecannotreconstructtheoriginalemployeerelation--andso,thisisalossydecomposition.©Silberschatz,KorthandSudarshan7.7DatabaseSystemConcepts-5thEdition,July28,2005.ALossyDecomposition©Silberschatz,KorthandSudarshan7.8DatabaseSystemConcepts-5thEdition,July28,2005.FirstNormalFormDomainisatomicifitselementsareconsideredtobeindivisibleunitsExamplesofnon-atomicdomains:Setofnames,compositeattributesIdentificationnumberslikeCS101thatcanbebrokenupintopartsArelationalschemaRisinfirstnormalformifthedomainsofallattributesofRareatomicNon-atomicvaluescomplicatestorageandencourageredundant(repeated)storageofdataExample:Setofaccountsstoredwitheachcustomer,andsetofownersstoredwitheachaccountWeassumeallrelationsareinfirstnormalform(andrevisitthisinChapter9)©Silberschatz,KorthandSudarshan7.9DatabaseSystemConcepts-5thEdition,July28,2005.FirstNormalForm(Cont’d)Atomicityisactuallyapropertyofhowtheelementsofthedomainareused.Example:StringswouldnormallybeconsideredindivisibleSupposethatstudentsaregivenrollnumberswhicharestringsoftheformCS0012orEE1127Ifthefirsttwocharactersareextractedtofindthedepartment,thedomainofrollnumbersisnotatomic.Doingsoisabadidea:leadstoencodingofinformationinapplicationprogramratherthaninthedatabase.©Silberschatz,KorthandSudarshan7.10DatabaseSystemConcepts-5thEdition,July28,2005.Goal—DeviseaTheoryfortheFollowingDecidewhetheraparticularrelationRisin“good”form.InthecasethatarelationRisnotin“good”form,decomposeitintoasetofrelations{R1,R2,...,Rn}suchthateachrelationisingoodformthedecompositionisalossless-joindecompositionOurtheoryisbasedon:functionaldependenciesmultivalueddependencies©Silberschatz,KorthandSudarshan7.11DatabaseSystemConcepts-5thEdition,July28,2005.FunctionalDependenciesConstraintsonthesetoflegalrelations.Requirethatthevalueforacertainsetofattributesdeterminesuniquelythevalueforanothersetofattributes.Afunctionaldependencyisageneralizationofthenotionofakey.©Silberschatz,KorthandSudarshan7.12DatabaseSystemConcepts-5thEdition,July28,2005.FunctionalDependencies(Cont.)LetRbearelationschemaRandRThefunctionaldependencyholdsonRifandonlyifforanylegalrelationsr(R),wheneveranytwotuplest1andt2ofragreeontheattributes,theyalsoagreeontheattributes.Thatis,t1[]=t2[]t1[]=t2[]Example:Considerr(A,B)withthefollowinginstanceofr.Onthisinstance,ABdoesNOThold,butBAdoeshold.141537©Silberschatz,KorthandSudarshan7.13DatabaseSystemConcepts-5thEdition,July28,2005.FunctionalDependencies(Cont.)KisasuperkeyforrelationschemaRifandonlyifKRKisacandidatekeyforRifandonlyifKR,andfornoK,RFunctionaldependenciesallowustoexpressconstrai
三七文档所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
本文标题:数据库系统概念5e-Chapter_7__Relational_Database_Design
链接地址:https://www.777doc.com/doc-4056493 .html