数据库管理系统概述英文版课件:4 Relational Model..pptx

上传人:聆听****声音 文档编号:370583 上传时间:2023-04-29 格式:PPTX 页数:55 大小:715.71KB
下载 相关 举报
数据库管理系统概述英文版课件:4 Relational Model..pptx_第1页
第1页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第2页
第2页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第3页
第3页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第4页
第4页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第5页
第5页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第6页
第6页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第7页
第7页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第8页
第8页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第9页
第9页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第10页
第10页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第11页
第11页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第12页
第12页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第13页
第13页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第14页
第14页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第15页
第15页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第16页
第16页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第17页
第17页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第18页
第18页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第19页
第19页 / 共55页
数据库管理系统概述英文版课件:4 Relational Model..pptx_第20页
第20页 / 共55页
亲,该文档总共55页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

数据库管理系统概述英文版课件:4 Relational Model..pptx

《数据库管理系统概述英文版课件:4 Relational Model..pptx》由会员分享,可在线阅读,更多相关《数据库管理系统概述英文版课件:4 Relational Model..pptx(55页珍藏版)》请在冰点文库上搜索。

数据库管理系统概述英文版课件:4 Relational Model..pptx

COMP231,COMP231,1,RelationalModel,Outline,IntroductionTerminologyER-to-RelationalMapping,COMP231,2,Introduction,COMP231,3,TherelationalmodelwasfirstintroducedbyTedCoddofIBMResearchin1970andattractedduetoitssimplicity,eleganceandmathematicalfoundationsThemodelusestheconceptofamathematicalrelationwhichlookslikeatableofvalues,Outline,IntroductionTerminologyER-to-RelationalMapping,COMP231,4,Terminology,COMP231,5,Relationtable;denotedbyR(A1,A2,.,An)whereRisarelationnameand(A1,A2,.,An)istherelationschemaofRAttribute(column)denotedbyAiTuple(Record)rowAttributevaluevaluestoredinatablecellDomaindenotedbydom(Ai),Attribute:

AgeAttribute:

EmpNameAttribute:

Salary,Domain:

0-100Domain:

50alphabeticcharsDomain:

non-negativeinteger,Terminology,Attributes/Columns(collectivelyasaschema),Tuples/Rows,RelationName/TableName,COMP231,6,Schema,Therelationschemais(Name,Student-id,Age,CGA)OR,Theprimarykeyisunderlinedintheabove,Name,Student-idAge,CGA,COMP231,7,ForeignKey,COMP231,8,Aforeignkeyisasetofattributesinonerelationrthatisusedtorefertoatupleinanotherrelations.(itmustcorrespondtotheprimarykeyofthesecondrelation),ForeignKey,COMP231,9,Student(Student-id,Student-Name)Take(Student-id,Course-id,semesterNo)Student-idinrelationStudentisaprimarykeyStudent-idinrelationTakeisaforeignkey,ForeignKey,COMP231,10,Student(Student-id,Student-Name)Take(Student-id,Course-id,semesterNo)Course(Course-id,Course-Name)Course-idinrelationCourseisaprimarykeyCourse-idinrelationTakeisaforeignkey,Outline,IntroductionTerminologyER-to-RelationalMapping,COMP231,11,ER-to-RelationalMapping,COMP231,12,Typically,databasedesignersbeginwiththeERmodel,whichisveryexpressiveanduser-friendlytohumanThen,theERmodelismappedtotherelationalmodelforDBMSmanipulationsDatabasequeriesandupdateswillbewrittenaccordingtotherelationalmodel,ER-to-RelationalMapping,TranslatingtraditionalERdiagramsTranslatingClassHierarchy,COMP231,13,Dependentt,name,sex,bdate,relationship,Controls,Project,pnamepnumber,plocation,supervision,supervisee,works_on,Dependentt_off,hours,Employee,sex,name,eid,bdate,addr,salarysupervisor,works_for,Manages,start_date,dnamenumberDepartment,COMP231,14,Controls,Project,pnamepnumber,plocation,works_on,hours,Employee,sex,name,eid,bdate,addr,salary,works_for,Manages,start_date,dnamenumberDepartment,COMP231,15,Steps,COMP231,16,Step1(StrongEntitySet)Step2(WeakEntitySet)Step3(1-to-1Relationship)Step4(1-to-manyRelationship)Step5(Many-to-manyRelationship)Step6(Non-binaryRelationship),Step1(StrongEntity),COMP231,17,ForeachstrongentitysetEintheERschema,createarelationschemaRthatincludesalltheattributesofE.chooseonesetofkeyattributesofEasaprimarykeyforR.,Dependentt,name,sex,bdate,relationship,Controls,Project,pnamepnumber,plocation,supervision,supervisee,works_on,Dependentt_off,hours,Employee,sex,name,eid,bdate,addr,salarysupervisor,works_for,Manages,start_date,dnamenumberDepartment,COMP231,18,Project,pnamepnumber,plocation,Employee,sex,name,eid,addr,bdatesalary,dnamenumberDepartment,COMP231,19,Step1(StrongEntity),ExampleWecreatetherelationschemasEMPLOYEE,DEPARTMENTandPROJECT.,name,EMPLOYEE,DEPARTMENT,PROJECT,eid,bdate,addr,sexsalary,dname,dnumber,pname,pnumber,plocation,COMP231,20,Ifthereisaderivedattribute,whatshouldwedo?

Wehavetwochoices.Choice1:

IncludethisderivedattributeAdv:

WecandirectlyobtainthevalueofthederivedattributeDisadv:

WemayencountersomedatainconsistenciesChoice2:

NOTincludethisderivedattributeAdv:

WecanavoiddatainconsistencyDisadv:

Weneedtoperformsomeoperationstoobtainthevalueofthederivedattribute,COMP231,21,Ifthereisacompositeattribute,whatshouldwedo?

Wehavetwochoices.Choice1:

Includethehigh-levelattributeonly(e.g.,address)Choice2:

Includealllow-levelattributes(e.g.,street,city,country),Employee,address,street,city,country,COMP231,22,Ifthereisamulti-valuedattribute,whatshouldwedo?

Wehavetwochoices.Choice1:

Includeoneattributeonly(e.g.,phone)Choice2:

Createanothertablecontainingtheprimarykeyoftheentitysetandthemulti-valuedattributee.g.,createaschemaPhoneTable(eid,phone),Employee,phone,eid,COMP231,23,Step2(WeakEntity),COMP231,24,ForeachweakentitysetWintheERmodel,createarelationschemaR,andincludeallattributes.Inaddition,includetheprimarykey(s)oftheowner(s).TheprimarykeyofRisthecombinationoftheprimarykey(s)oftheowner(s)andthediscriminatoroftheweakentitysetW.,Dependentt,name,sex,bdate,relationship,Controls,Project,pnamepnumber,plocation,supervision,supervisee,works_on,Dependentt_off,hours,Employee,sex,name,eid,bdate,addr,salarysupervisor,works_for,Manages,start_date,dnamenumberDepartment,COMP231,25,Dependentt,name,sex,bdate,relationship,Dependentt_off,sex,name,addr,eidEmployeebdatesalary,COMP231,26,Dependenteiddependent-name,sexbdate,relationship,COMP231,27,Step3(1-to-1Relationship),COMP231,28,Foreachbinaryone-to-one(1:

1)relationshipsetRT-SChooseoneofthe2relationschemas,sayS,getprimarykeyofT,includeitasforeignkeysinS.BetterifShastotalparticipationinRIncludetheattributesoftherelationshipsetRasattributesofS.,Dependentt,name,sex,bdate,relationship,Controls,Project,pnamepnumber,plocation,supervision,supervisee,works_on,Dependentt_off,hours,Employee,sex,name,eid,bdate,addr,salarysupervisor,works_for,Manages,start_date,dnamenumberDepartment,COMP231,29,Employee,sex,name,eid,bdate,addr,salary,Manages,start_date,dnamenumberDepartment,COMP231,30,WeincludetheprimarykeyofEMPLOYEEasforeignkeyinDEPARTMENTandrenameitmgr_id.WeincludetheattributestartdateofMANAGESandrenameitmgr_start_date.,DEPARTMENT,dnamednumbermgr_idmgr_start_date,COMP231,31,ComparethefollowingtwochoicestoincludeMANAGES:

AddinformationtoEMPLOYEE,AddtoDEPARTMENT,EMPLOYEE,MANAGES,DEPARTMENT,COMP231,32,total.,Intheabove,theNULLvalueisaspecialvaluemeaningthatthevalueiseitherunknownornotapplicable.Noticethatanalternativemappingofaone-to-onerelationshipsetispossiblebymergingthetwoentitysetsandtherelationshipintoasinglerelation.ThisisappropriatewhenbothparSttiecpip3a:

tionsare,Advantage:

ThetotalnumberofrelationsremainunchangedDisadvantage:

ItmaystoreNULLvaluesifthereisnototalparticipation,COMP231,33,Employee,sex,name,eid,bdate,addr,salary,Manages,start_date,dnamenumberDepartment,Canwecreateanewrelation,Manages(eid,number,start_date),Or,Manages(eid,number,start_date),forthisrelationship?

Yes.,ItcanbeusedifthereareonlyafewrelationshipinstancesAdvantage:

ItcanavoidstoringNULLvaluesifthereisnototalparticipationDisadvantage:

Thereisoneadditionalrelation,COMP231,34,Step4(1-to-manyRelationship),COMP231,35,Foreachbinaryone-to-manyrelationshipsetT-SIncludeasforeignkeyinStheprimarykeythatrepresentstheotherentitysetTparticipatinginR.Includeanyattributesoftheone-to-manyrelationshipsetasattributesofS.,Dependentt,name,sex,bdate,relationship,Controls,Project,pnamepnumber,plocation,supervision,supervisee,works_on,Dependentt_off,hours,Employee,sex,name,eid,bdate,addr,salarysupervisor,works_for,Manages,start_date,dnamenumberDepartment,COMP231,36,Controls,Project,pnamepnumber,plocation,supervision,supervisee,Employee,sex,name,eid,bdate,addr,salarysupervisor,works_for,dnamenumberDepartment,COMP231,37,TheprimarykeydnumberoftheDEPARTMENTrelationschemaisincludedasforeignkeyintheEMPLOYEErelationschema.Werenameitasdno.(Therenamingisnotnecessarybutmakesthenamemoremeaningful.),EMPLOYEE,nameeidbdateaddrsexsalarydnoEMPLOYEEWORKS_FORDEPARTMENT,COMP231,38,EMPLOYEE,Comparethefollowing2choices:

DEPARTMENT,Addemployeestodepartment,COMP231,Adddepartmenttoemployee,39,ForSUPERVISON,includetheprimarykeyoftheEMPLOYEEasforeignkeyintheEMPLOYEE,andcallitsuper_id.,nameeidbdateaddrsexsalarydnosuper_id,EMPLOYEE,pnamepnumberplocationdnum,COMP231,40,PROJECT,ForCONTROLSrelationship,includednumasforeignkeyinPROJECT,whichreferencestheprimarykeydnumberofDEPARTMENT.,Controls,Project,pnamepnumber,plocation,supervision,supervisee,Employee,sex,name,eid,bdate,addr,salarysupervisor,works_for,dnamenumberDepartment,Canwecreateanewrelation,works_for(eid,number),forthisrelationship?

Yes.,COMP231,41,Step5(Many-to-manyRelationship),COMP231,42,Foreachbinarymany-to-manyrelationshipsetR,createanewrelationschemaStorepresentR.IncludeasforeignkeyattributesinStheprimarykeysoftherelationschemasfortheparticipatingentitysetsinRtheircombinationwillformtheprimarykeyofS.Alsoincludeattributesofthemany-to-manyrelationshipsetasattributesofS.,Dependentt,name,sex,bdate,relationship,Controls,Project,pnamepnumber,plocation,supervision,supervisee,works_on,Dependentt_off,hours,Employee,sex,name,eid,bdate,addr,salarysupervisor,works_for,Manages,start_date,dnamenumberDepartment,COMP231,43,Project,pnamepnumber,plocation,hoursworks_on,sex,name,addr,eidEmployeebdatesalary,COMP231,44,Mapthemany-to-manyrelationshipsetsWORKS_ONbycreatingtherelationschemaWORKS_ON.IncludetheprimarykeysofPROJECTandEMPLOYEEasforeignkeys.,eidpnumberhours,COMP231,45,WORKS_ON,Comparethefollowingthreechoicestoincludeworks_on,AddtoEMPLOYEE,AddtoPROJECT,NewrelationWORKS_ON,WORKS_ONEMPLOYEEPROJECT,COMP231,46,Step6(Non-binaryRelationship),COMP231,47,Foreachnon-binaryrelationshipset,createanewrelationschemaStorepresentR.IncludeasforeignkeyattributesinStheprimarykeysoftheparticipatingentitysets.Alsoincludeanyattributesofthenon-binaryrelationshipsetasattributesofS.,Fornon-binaryrelationships,TheprimarykeyofSisusuallyacombinationofalltheforeignk

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2