第4讲-概念模型设计PPT课件.ppt_第1页
第4讲-概念模型设计PPT课件.ppt_第2页
第4讲-概念模型设计PPT课件.ppt_第3页
第4讲-概念模型设计PPT课件.ppt_第4页
第4讲-概念模型设计PPT课件.ppt_第5页
已阅读5页,还剩33页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第3部分 概念模型设计教师 朱征宇单位 重庆大学计算机学院 课程名称 数据库系统 1 提纲 数据库设计过程实体联系模型重复属性的处理实体联系图数据流图到ER图 2 3 主要任务 为一个应用设计数据库是一个极其复杂的任务 通常需要考虑 数据库模式 优良的数据结构 数据访问与更新方式 高效的数据存取 数据访问的安全模式 可靠的数据安全 数据的物理存储模式 存放位置与次序 以及数据约束 等多个任务首要难题 数据库设计者必须与应用的用户进行交互以理解应用的需求 并把它们用高层次 抽象 概念模型 的形式表示出来 便于用户理解 确认和提出修改建议 客观模型然后才考虑如何将其设计转化为便于在计算机上实现的更低层次 逻辑存储模式 关系模式 物理存储模式等 主观模型 数据库设计的主要任务 一数据库设计过程 DBS设计 数据库设计 设计时的首要难题是什么 4 数据库设计的前期基础 明确应用需求 应用边界 完整的了解和刻画出未来数据库系统的功能应用与数据需求 数据流图 数据建模阶段 概念设计 选择数据模型 将需求转化为概念模型模型修正 用户确认 核实是否满足企业的应用 功能 需求 并不断完善概念模型 逻辑结构设计阶段 逻辑设计 概念模型映射到系统选用的商业产品数据模型 逻辑模型 数据物理组织阶段 物理设计 根据逻辑模型和应用访问要求 进行物理设计 物理模型 数据库设计完成之后的工作 数据库实现 创建结构 根据逻辑设计和物理设计要求 实际建立应用的数据结构比如 采用SQL语言创建关系数据模式 数据库设计的基本过程 一数据库设计过程 数据库设计的基本阶段 返回讨论页 开展数据库设计的前期基础 更准确 细化 地讲 还应当包括数据完整性和安全性设计阶段 5 EntitySets Adatabasecanbemodeledas acollectionofentities relationshipamongentities Anentityisanobjectthatexistsandisdistinguishablefromotherobjects Example specificperson company event plantEntitieshaveattributesExample peoplehavenamesandaddressesAnentitysetisasetofentitiesofthesametypethatsharethesameproperties Example setofallpersons companies trees holidays 二实体联系模型 E R模型 对数据库结构的描述应当包括哪些方面 2 1实体集 如何抽象地描述客观对象的内部结构 有哪些客观对象 以及相互间的联系 6 EntitySetsinstructorandstudent例子 instructor ID instructor namestudent ID student name 2 1实体集 7 RelationshipSets ArelationshipisanassociationamongseveralentitiesExample 44553 Peltier advisor22222 Einstein studententityrelationshipsetinstructorentityArelationshipsetisamathematicalrelationamongn 2entities eachtakenfromentitysets e1 e2 en e1 E1 e2 E2 en En where e1 e2 en isarelationshipExample 44553 22222 advisor 如何抽象地描述客观对象间的关联 2 2联系集 爱因斯坦 8 RelationshipSetadvisor例子 2 2联系集 这里的联系集具体是指什么关系 table lines 9 RelationshipSets Cont Anattributecanalsobepropertyofarelationshipset Forinstance theadvisorrelationshipsetbetweenentitysetsinstructorandstudentmayhavetheattributedatewhichtrackswhenthestudentstartedbeingassociatedwiththeadvisor 2 2联系集 联系也可以有属性吗 10 Degree度ofaRelationshipSet binaryrelationshipinvolvetwoentitysets ordegreetwo mostrelationshipsetsinadatabasesystemarebinary Relationshipsbetweenmorethantwoentitysetsarerare Mostrelationshipsarebinary Moreonthislater Example studentsworkonresearchprojectsundertheguidanceofaninstructor relationshipproj guideisaternary三重的relationshipamonginstructor student andproject ordegreethree 2 2联系集 联系集的度是指什么 教师工号 学号 项目名称 又例 教室 学生 课程之间的联系 教室编号 学号 课程号 11 Attributes Anentityisrepresentedbyasetofattributes thatisdescriptive描述propertiespossessedbyallmembersofanentityset Example instructor ID name street city salary course course id title credits Domain thesetofpermittedvaluesforeachattributeAttributetypes 允许符合结构等复杂属性SimpleandcompositeattributesSingle valuedandmultivaluedattributesExample multivaluedattribute phone numbersDerivedattributesCanbecomputedfromotherattributesExample age givendate of birth 2 3属性 E R模型允许什么类型的属性 12 CompositeAttributes 2 3属性 什么是复合属性 复合的 构成的 13 MappingCardinalityConstraints Expressthenumberofentitiestowhichanotherentitycanbeassociatedviaarelationshipset Mostusefulindescribingbinaryrelationshipsets Forabinaryrelationshipsetthemappingcardinalitymustbeoneofthefollowingtypes OnetooneOnetomanyManytooneManytomany 什么是映射基数 2 4映射基数约束 14 MappingCardinalities例子 Note SomeelementsinAandBmaynotbemappedtoanyelementsintheotherset 这些映射基数表示什么现象 2 4映射基数约束 15 KeysofEntitySets Asuperkeyofanentitysetisasetofoneormoreattributeswhosevaluesuniquelydetermineeachentity AcandidatekeyofanentitysetisaminimalsuperkeyIDiscandidatekeyofinstructorcourse idiscandidatekeyofcourseAlthoughseveralcandidatekeysmayexist oneofthecandidatekeysisselectedtobetheprimarykey 2 5实体集和联系集的 键 16 KeysforRelationshipSets Thecombinationofprimarykeysoftheparticipatingentitysetsformsasuperkeyofarelationshipset s id i id isthesuperkeyofadvisorNOTE thismeansapairofentitysetscanhaveatmostonerelationshipinaparticularrelationshipset Example ifwewishtotrackmultiplemeetingdatesbetweenastudentandheradvisor wecannotassumearelationshipforeachmeeting WecanuseamultivaluedattributethoughMustconsiderthemappingcardinalityoftherelationshipsetwhendecidingwhatarethecandidatekeysNeedtoconsidersemanticsofrelationshipsetinselectingtheprimarykeyincaseofmorethanonecandidatekey 2 5实体集和联系集的键 联系集的键由什么构成 通常 但有例外 如1 N时仅由N方构成 由参与该联系各实体集的键合并构成 返回讨论页 17 RedundantAttributes Supposewehaveentitysetsinstructor withattributesincludingdept name ortheNo ofthedepartment departmentandarelationshipinst deptrelatinginstructoranddepartmentAttributedept name orNo inentityinstructorisredundantsincethereisanexplicitrelationshipinst deptwhichrelatesinstructorstodepartmentsTheattributereplicatesinformationpresentintherelationship andshouldberemovedfrominstructorBUT whenconvertingbacktotables insomecasestheattributegetsreintroduced aswewillsee 三重复属性的处理 哪些类型的重复属性最容易出现 如何避免 又比如 教室实体集中的教室编号属性 同时在学生 课程 教师等实体集中出现 返回讨论页 18 E RDiagrams Rectanglesrepresententitysets Diamondsrepresentrelationshipsets Attributeslistedinsideentityrectangle 常用椭圆型 Underlineindicatesprimarykeyattributes 四实体联系图 E R图 什么是实体联系图 采用E R模型方法 符号和图的方式 对客观数据的描述结果 4 1E R图的基本图符 19 EntitySetWithComposite Multivalued andDerivedAttributes 复杂实体集的图表示 实体集如何图示 4 1E R图基本图符 20 RelationshipSetswithAttributes 联系集的图表示 联系集如何图示 4 1E R图基本图符 21 Roles EntitysetsofarelationshipneednotbedistinctEachoccurrence每条联线ofanentitysetplaysa role intherelationshipThelabels course id and prereq id arecalledroles 什么是联系集的角色 如何图示 一门课程的先修课 4 1E R图基本图符 22 CardinalityConstraints Weexpresscardinalityconstraintsbydrawingeitheradirectedline signifying one oranundirectedline signifying many betweentherelationshipsetandtheentityset One to onerelationship AstudentisassociatedwithatmostoneinstructorviatherelationshipadvisorAstudentisassociatedwithatmostonedepartmentviastud dept 联系集的类型 基数约束 如何图示 4 2联系集基数约束的表示 23 One to OneRelationship one to onerelationshipbetweenaninstructorandastudentaninstructorisassociatedwithatmostonestudentviaadvisorandastudentisassociatedwithatmostoneinstructorviaadvisor 该联系集为什么类型 4 2联系集基数约束的表示 24 One to ManyRelationship one to manyrelationshipbetweenaninstructorandastudentaninstructorisassociatedwithseveral including0 studentsviaadvisorastudentisassociatedwithatmostoneinstructorviaadvisor 该联系集为什么类型 4 2联系集基数约束的表示 25 Many to OneRelationships Inamany to onerelationshipbetweenaninstructorandastudent aninstructorisassociatedwithatmostonestudentviaadvisor andastudentisassociatedwithseveral including0 instructorsviaadvisor 该联系集为什么类型 4 2联系集基数约束的表示 26 Many to ManyRelationship Aninstructorisassociatedwithseveral possibly0 studentsviaadvisorAstudentisassociatedwithseveral possibly0 instructorsviaadvisor 该联系集为什么类型 返回 4 2联系集基数约束的表示 27 AlternativeNotationforCardinalityLimits Cardinalitylimitscanalsoexpressparticipationconstraints 什么是 参与约束 基数比 表示何含义 4 2联系集基数约束的表示 1 M类型的联系 前面介绍的 基数约束 不同表示方式 28 ParticipationofanEntitySetinaRelationshipSet Totalparticipation indicatedbydoubleline 全参与everyentityintheentitysetparticipatesinatleastonerelationshipintherelationshipsetE g participationofsectioninsec courseistotaleverysectionmusthaveanassociatedcoursePartialparticipation indicatedbysingleline 部分参与someentitiesmaynotparticipateinanyrelationshipintherelationshipsetExample participationofinstructorinadvisorispartial 联系集是否为 全参与 如何区分 4 3联系集全参与约束的表示 29 E RDiagramwithaTernary三元Relationship 如何解释该三元联系的含义 返回 4 4三元联系 还有四元联系等多元联系吗 30 CardinalityConstraintsonTernaryRelationship Weallowatmostonearrowoutofaternary orgreaterdegree relationshiptoindicateacardinalityconstraintE g anarrowfromproj guidetoinstructorindicateseachstudenthasatmostoneguideforaproject If假如thereismorethanonearrow therearetwowaysofdefiningthemeaning E g aternaryrelationshipRbetweenA BandCwitharrowstoBandCcouldmean 1 eachAentityisassociatedwithauniqueentityfromBandC or2 eachpairofentitiesfrom A B isassociatedwithauniqueCentity andeachpair A C isassociatedwithauniqueBEachalternativehasbeenusedindifferentformalisms不同场合Toavoidconfusionweoutlaw取缔morethanonearrow 三元联系集的参与约束可以如何表示 4 4三元联系 31 WeakEntitySets Anentitysetthatdoesnothaveaprimarykeyisreferredtoasaweakentityset 弱实体集Theexistenceofaweakentitysetdependsontheexistenceofanidentifyingentityset主实体集Itmustrelatetotheidentifyingentitysetviaatotal 全参与 one to manyrelationshipsetfromtheidentifyingtotheweakentitysetIdentifyingrelationshipdepictedusingadoublediamondThediscriminator分辨符 orpartialkey ofaweakentitysetisthesetofattributesthatdistinguishesamongalltheentitiesofaweakentityset Theprimarykeyofaweakentitysetisformedbytheprimarykeyofthestrongentityset强实体集onwhichtheweakentitysetisexistencedependent plustheweakentityset sdiscriminator 4 5弱实体集 弱实体集表示什么样的客观实体 对象 弱实体集如何图示 键由什么属性组成 32 WeakEntitySets

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论