已阅读5页,还剩55页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1 PrenticeHall 2002 Chapter6 LogicalDatabaseDesignandtheRelationalModel JIANGMINCOMP256 2 PrenticeHall 2002 Overview ObjectiveistotranslatetheconceptualdatamodelintoalogicaldatabasedesignthatcanbeimplementedonachosenDBMSNotationforrelationaldatamodelIntegrityConstraintsTransformingERDtorelationalmodelNormalizationandNormalForm NF 3 PrenticeHall 2002 RelationalDataModel RepresentsdataintheformoftablesDataStructureDataorganizedintheformoftableswithrowsandcolumnsDataManipulationOperationstomanipulatethedatastoredinthetablesDataIntegrityFacilitiestospecifybusinessrulesthatmaintaintheintegrityofthedatawhenmanipulated 4 PrenticeHall 2002 RelationalDataModel RelationNamedtwodimensionaltableofdataSetofnamedcolumnsArbitrarynumberofrows 5 PrenticeHall 2002 RelationalDataModel Relationshowingsampledata Fields Attributes columns Tuples Records Rows 6 PrenticeHall 2002 RelationalNotation EMPLOYEE1 Emp ID Name Dept Name Salary DEPARTMENT Dept Name Location EMPLOYEE1 7 PrenticeHall 2002 CorrespondencewithERModel Relations tables correspondwithentitytypesandwithmany to manyrelationshiptypesRowscorrespondwithentityinstancesandwithmany to manyrelationshipinstancesColumnscorrespondwithattributesNOTE Thewordrelation inrelationaldatabase isNOTthesamesamethewordrelationship inERmodel 8 PrenticeHall 2002 KeyFields Primarykey Msaccess Anattribute orcombination thatuniquelyidentifieseachrowinarelationForeignkey eg Representsrelationshipbetween2tablesAttribute orcombination inarelationthatistheprimarykeyofanotherrelationinsamedatabaseCompositekeyKeyconsistsofmorethanoneattribute 9 PrenticeHall 2002 Figure6 5 Schemaforfourrelations PineValleyFurniture 10 PrenticeHall 2002 NotalltablesqualifyasrelationsRequirements MSaccess Everyrelationhasauniquename Attributes columns intableshaveuniquenamesTheorderofthecolumnsisirrelevantTheorderoftherowsisirrelevantEveryattributevalueisatomic notmultivalued notcomposite Everyrowisunique can thavetworowswithexactlythesamevaluesforalltheirfields 11 PrenticeHall 2002 Everyattributevalueisatomic notmultivalued notcomposite 12 PrenticeHall 2002 13 PrenticeHall 2002 Eg2 14 PrenticeHall 2002 RelationalDatabase ConsistsofanynumberofrelationsStructuredescribedthroughuseofconceptualschemaTWOmethodsforexpressingaschema ShorttextstatementsusingrelationalnotationGraphicallikeERDbutwithattributeslistedwithintherectangleforeachrelation 15 PrenticeHall 2002 CUSTOMER ORDER ORDER LINE PRODUCT Exampleschemafromtextbook p212 16 PrenticeHall 2002 TextualNotationCUSTOMER Customer ID Customer Name Address City State Zip ORDER Order ID Order Date Customer ID ORDER LINE Order ID Product ID Quantity PRODUCT Product ID Product Description Product Finish Unit Price On Hand NoteCustomer IDisFKeyonORDERBothOrder IDandProduct IDareFkeyonORDER LINE butdifficulttoshow 17 PrenticeHall 2002 DiagramNotation LikePowerDesignerorOracleDesigner 2000 18 PrenticeHall 2002 IntegrityConstraints PurposeistofacilitatemaintainingaccuracyandintegrityofdatainthedatabaseDomainConstraintsEntityIntegrityReferentialIntegrityOperationalConstraints 19 PrenticeHall 2002 domainconstraint Specificationofthesetofvaluesthatcanbeassigneddomainnamemeaningordescriptiondatatypesize length decimalplaces etc allowablevalues listorrange DomainConstraints 20 PrenticeHall 2002 EntityIntegrity Designedtoensureeveryrelationhasauniqueprimarykeyasawayofidentifyingaspecificrow rowuniquenessproperty Noprimarykeyattribute orcomponent canbeNULL 21 PrenticeHall 2002 NULLvalue Therearecaseswhenanattributecannotbeassignedavalue Thereisnovalueapplicableeg PersonalFAXnumberThevalueisnotknownwhenrowiscreatedeg GPAfornewlyregisteredstudentNULLisemptyormissingorabsentvalueNotthesameasblankorzero eg meaningifGPAisNULLversus0 00 22 PrenticeHall 2002 ReferentialIntegrity DesignedtomaintainconsistencyofrelationshipsbetweentablesEachforeignkeyvaluemustmatchaprimarykeyvalueintheotherrelation orelsetheforeignkeyvaluemustbenullParent Childeg cannotcreateanOrderunlessCustomerexists 23 PrenticeHall 2002 Figure5 5 Referentialintegrityconstraints PineValleyFurniture Referentialintegrityconstraintsaredrawnviaarrowsfromdependenttoparenttable 24 PrenticeHall 2002 Well StructuredRelations Arelationthatcontainsminimaldataredundancyandallowsuserstoinsert delete andupdaterowswithoutcausingdatainconsistenciesGoalistoavoidanomaliesInsertionAnomaly addingnewrowsforcesusertocreateduplicatedataDeletionAnomaly deletingrowsmaycausealossofdatathatwouldbeneededforotherfuturerowsUpdateAnomaly changingdatainarowforceschangestootherrowsbecauseofduplication 25 PrenticeHall 2002 Example Figure5 2b Question Isthisarelation Answer Yes uniquerowsandnomultivaluedattributes Question What stheprimarykey Answer Composite Emp ID Course Title 26 PrenticeHall 2002 AnomaliesinthisTable Insertion can tenteranewemployeewithouthavingtheemployeetakeaclassDeletion ifweremoveemployee140 weloseinformationabouttheexistenceofaTaxAccclassUpdate givingasalaryincreasetoemployee100forcesustoupdatemultiplerecords 27 PrenticeHall 2002 EMPLOYEE1 EMP COURSE EMPLOYEE2 28 PrenticeHall 2002 DataNormalization PrimarilyatooltovalidateandimprovealogicaldesignsothatitsatisfiescertainconstraintsthatavoidunnecessaryduplicationofdataTheprocessofdecomposingrelationswithanomaliestoproducesmaller well structuredrelations 29 PrenticeHall 2002 FunctionalDependenciesandKeys FunctionalDependency Thevalueofoneattribute thedeterminant determinesthevalueofanotherattributeCandidateKey Auniqueidentifier OneofthecandidatekeyswillbecometheprimarykeyE g perhapsthereisbothcreditcardnumberandSS inatable inthiscasebotharecandidatekeysEachnon keyfieldisfunctionallydependentoneverycandidatekey 30 PrenticeHall 2002 Normalization NormalizationProcessofdecomposingrelationswithanomaliestoproducesmallerwell structuredrelationsNormalFormAstateofarelationthatresultsfromapplyingrulesregardingfunctionaldependencies orrelationshipsbetweenattributes tothatrelation 31 PrenticeHall 2002 Normalization Firstnormalform Secondnormalform Thirdnormalform Boyce Coddnormalform Fourthnormalform Fifthnormalform Removemulti valuedattributes Removeremaininganomalies Removemulti valueddependencies Removepartialdependencies Removetransitivedependencies Removeremainingfunctionaldependencies 32 PrenticeHall 2002 Definition constraintbetweentwoattributesortwosetsofattributesThevalueofoneattribute thedeterminant determinesthevalueofanotherattributeA BBisfunctionallydependantonAAiscalledthedeterminantSIN Name Birthdate Address ISBN Title AuthorEmp ID Course Name Date Completedeg FunctionalDependencies 33 PrenticeHall 2002 CandidateKey Definition Attribute orcombination thatuniquelyidentifiesarowinarelationOneofthecandidatekeyswillbecometheprimarykeyE g perhapsthereisbothcreditcardnumberandSS inatable inthiscasebotharecandidatekeys 34 PrenticeHall 2002 CandidateKey Mustsatisfysubsetofprimarykeyproperties UniqueIdentificationImpliesthateachnonkeyattributeisfunctionallydependentonthatkeyNon redundancyNoattributeinthekeycanbedeletedwithoutdestroyingthepropertyofuniqueidentification 35 PrenticeHall 2002 CandidateKeyMustsatisfysubsetofprimarykeyproperties UniqueIdentificationImpliesthateachnonkeyattributeisfunctionallydependentonthatkeyNon redundancyNoattributeinthekeycanbedeletedwithoutdestroyingthepropertyofuniqueidentification 36 PrenticeHall 2002 EMPLOYEE1 FunctionalDependencies EMPLOYEE2 37 PrenticeHall 2002 Arelationwhichcontainsnomulti valuedattributes noarrays 1NF FirstNormalForm 38 PrenticeHall 2002 Figure5 10 Mappingamultivaluedattribute a 39 PrenticeHall 2002 40 PrenticeHall 2002 2NF SecondNormalForm Arelationthatisin1NFandhaveeverynon keyattributefullyfunctionallydependentontheprimarykeyeg EMPLOYEE2PartialfunctionaldependencyOneormorenon keyattributesaredependentonpart butnotall theprimarykey 41 PrenticeHall 2002 Fig5 23 b FunctionalDependenciesinEMPLOYEE2 Dependencyonentireprimarykey Dependencyononlypartofthekey EmpID CourseTitle DateCompleted EmpID Name DeptName Salary Therefore NOTin2ndNormalForm 42 PrenticeHall 2002 Gettingitinto2ndNormalForm Seep193 decomposedintotwoseparaterelations Botharefullfunctionaldependencies 43 PrenticeHall 2002 EMPLOYEE1 EMP COURSE EMPLOYEE2 44 PrenticeHall 2002 Guarantee2NFifrelationis1NFandeitherPrimarykeyisasingleattributeNonon keyattributesinrelation everyattributeispartofthekey 45 PrenticeHall 2002 3NF ThirdNormalForm Arelationthatisin2NFandhasnotransitivedependenciespresentTransitiveDependencyFunctionaldependencybetweentwoormorenon keyattributes 46 PrenticeHall 2002 3NF ThirdNormalForm Figure6 24 TransitiveDependency 47 PrenticeHall 2002 Figure5 24 b Relationwithtransitivedependency CustID NameCustID SalespersonCustID RegionAllthisisOK 2ndNF 48 PrenticeHall 2002 3NF ThirdNormalForm 49 PrenticeHall 2002 Figure5 25 b Relationsin3NF Now therearenotransitivedependencies Bothrelationsarein3rdNF CustID NameCustID Salesperson Salesperson Region 50 PrenticeHall 2002 OtherNormalForms fromAppendixB Boyce CoddNFAlldeterminantsarecandidatekeys thereisnodeterminantthatisnotauniqueidentifier4thNFNomultivalueddepe
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 物联网导论配套课件
- 超声复合电导治疗仪
- 艾滋病工作年终经验介绍
- 2024年店铺租赁合同协议格式范文(2篇)
- 2024年单位端午节活动总结(2篇)
- 各种企业司机的岗位职责(2篇)
- 成本控制部职责具体内容(2篇)
- 2021年10月广西南宁市江南区科学技术局公开招聘强化练习卷(一)
- 2021年10月广西来宾市忻城县农业农村局编外聘用工作人员公开招聘模拟题(一)
- 2024年儿科护士个人工作总结(4篇)
- 运维培训课件
- 慢性咳嗽中医护理宣教
- 伐檀课件教案
- 供应链中心组织架构
- 小学教育中的体验式学习方法
- 《机房技术培训》课件
- 装载机操作安全规程培训
- 透析中低血压的预防及防治
- Part1-2 Unit5 Ancient Civilization教案-【中职专用】高一英语精研课堂(高教版2021·基础模块2)
- 学校宿舍家具采购投标方案技术标
- 足疗店应急处理预案模板
评论
0/150
提交评论