Ch数据库原理实用.pptx

上传人:莉*** 文档编号:73646092 上传时间:2023-02-21 格式:PPTX 页数:17 大小:289.09KB
返回 下载 相关 举报
Ch数据库原理实用.pptx_第1页
第1页 / 共17页
Ch数据库原理实用.pptx_第2页
第2页 / 共17页
点击查看更多>>
资源描述

《Ch数据库原理实用.pptx》由会员分享,可在线阅读,更多相关《Ch数据库原理实用.pptx(17页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、Conceptual designConceptual design:(ER Model is used at this stage.)What are the entities and relationships in the enterprise?What information about these entities and relationships should we store in the database?What are the integrity constraints or business rules that hold?A database schema in th

2、e ER Model can be represented pictorially(ER diagrams).Can map an ER diagram into a relational schema.第2页/共17页第1页/共17页ER Model BasicsEntity:Real-world object distinguishable from other objects.An entity is described(in DB)using a set of attributes.Entity Set:A collection of similar entities.E.g.,all

3、 employees.All entities in an entity set have the same set of attributes.(Until we consider ISA hierarchies,anyway!)Each entity set has a key.Each attribute has a domain.EmployeesssnnamelotKey is a minimal set of attributes whose values uniquely identify an entity in the set第3页/共17页第2页/共17页ER Model

4、Basics(Contd.)Relationship:Association among two or more entities.E.g.,Lisen works in Computer department.Relationship Set:Collection of similar relationships.An n-ary relationship set R relates n entity sets E1.En;each relationship in R involves entities e1 E1,.,en EnSame entity set could participa

5、te in different relationship sets,or in different“roles”in same set.lotdnamebudgetdidsincenameWorks_InDepartmentsEmployeesssnReports_TolotnameEmployeessubor-dinatesuper-visorssn第4页/共17页第3页/共17页Key ConstraintsConsider Works_In:An employee can work in many departments;a dept can have many employees.In

6、 contrast,each dept has at most one manager,according to the key constraint on Manages.Many-to-Many1-to-11-to ManyMany-to-1dnamebudgetdidsincelotnamessnManagesEmployeesDepartments第5页/共17页第4页/共17页Participation ConstraintsDoes every department have a manager?If so,this is a participation constraint:th

7、e participation of Departments in Manages is said to be total(vs.partial).Every did value in Departments table must appear in a row of the Manages table(with a non-null ssn value!)lotnamednamebudgetdidsincenamednamebudgetdidsinceManagessinceDepartmentsEmployeesssnWorks_In第6页/共17页第5页/共17页Weak Entitie

8、sA weak entity can be identified uniquely only by considering the primary key of another(owner)entity.Owner entity set and weak entity set must participate in a one-to-many relationship set(one owner,many weak entities).Weak entity set must have total participation in this identifying relationship s

9、et.lotnameagepnameDependentsEmployeesssnPolicycost第7页/共17页第6页/共17页ISA(is a)HierarchiesContract_EmpsnamessnEmployeeslothourly_wagesISAHourly_Empscontractidhours_workedvAs in C+,or other PLs,attributes are inherited.vIf we declare A ISA B,every A entity is also considered to be a B entity.Overlap cons

10、traints:Can Joe be an Hourly_Emps as well as a Contract_Emps entity?(Allowed/disallowed)Covering constraints:Does every Employees entity also have to be an Hourly_Emps or a Contract_Emps entity?(Yes/no)Reasons for using ISA:To add descriptive attributes specific to a subclass.To identify entitities

11、that participate in a relationship.第8页/共17页第7页/共17页AggregationUsed when we have to model a relationship involving(entitity sets and)a relationship set.Aggregation allows us to treat a relationship set as an entity set for purposes of participation in(other)relationships.*Aggregation vs.ternary relat

12、ionship:v Monitors is a distinct relationship,with a descriptive attribute.v Also,can say that each sponsorship is monitored by at most one employee.budgetdidpidstarted_onpbudgetdnameuntilDepartmentsProjectsSponsorsEmployeesMonitorslotnamessnsince第9页/共17页第8页/共17页Conceptual Design Using the ER ModelD

13、esign choices:Should a concept be modeled as an entity or an attribute?Should a concept be modeled as an entity or a relationship?Identifying relationships:Binary or ternary?Aggregation?Constraints in the ER Model:A lot of data semantics can(and should)be captured.But some constraints cannot be capt

14、ured in ER diagrams.第10页/共17页第9页/共17页Entity vs.AttributeShould address be an attribute of Employees or an entity(connected to Employees by a relationship)?Depends upon the use we want to make of address information,and the semantics of the data:If we have several addresses per employee,address must

15、be an entity(since attributes cannot be set-valued).If the structure(city,street,etc.)is important,e.g.,we want to retrieve employees in a given city,address must be modeled as an entity(since attribute values are atomic).第11页/共17页第10页/共17页Entity vs.Attribute(Contd.)Works_In2 does not allow an emplo

16、yee to work in a department for two or more periods.Similar to the problem of wanting to record several addresses for an employee:we want to record several values of the descriptive attributes for each instance of this relationship.nameEmployeesssnlotWorks_In2fromtodnamebudgetdidDepartmentsdnamebudg

17、etdidnameDepartmentsssnlotEmployeesWorks_In3Durationfromto第12页/共17页第11页/共17页Binary vs.Ternary RelationshipsIf each policy is owned by just 1 employee:Key constraint on Policies would mean policy can only cover 1 dependent!What are the additional constraints in the 2nd diagram?agepnameDependentsCover

18、snameEmployeesssnlotPoliciespolicyidcostBeneficiaryagepnameDependentspolicyidcostPoliciesPurchasernameEmployeesssnlotBad designBetter design第13页/共17页第12页/共17页Binary vs.Ternary Relationships(Contd.)Previous example illustrated a case when two binary relationships were better than one ternary relation

19、ship.An example in the other direction:a ternary relation Contracts relates entity sets Parts,Departments and Suppliers,and has descriptive attribute qty.No combination of binary relationships is an adequate substitute:S“can-supply”P,D“needs”P,and D “deals-with”S does not imply that D has agreed to

20、buy P from S.How do we record qty?第14页/共17页第13页/共17页Summary of Conceptual DesignConceptual design follows requirements analysis,Yields a high-level description of data to be stored ER model popular for conceptual designConstructs are expressive,close to the way people think about their applications.

21、Basic constructs:entities,relationships,and attributes(of entities and relationships).Some additional constructs:weak entities,ISA hierarchies,and aggregation.Note:There are many variations on ER model.第15页/共17页第14页/共17页Summary of ER(Contd.)Several kinds of integrity constraints can be expressed in

22、the ER model:key constraints,participation constraints,and overlap/covering constraints for ISA hierarchies.Some foreign key constraints are also implicit in the definition of a relationship set.Some constraints(notably,functional dependencies)cannot be expressed in the ER model.Constraints play an

23、important role in determining the best database design for an enterprise.第16页/共17页第15页/共17页Summary of ER(Contd.)ER design is subjective.There are often many ways to model a given scenario!Analyzing alternatives can be tricky,especially for a large enterprise.Common choices include:Entity vs.attribut

24、e,entity vs.relationship,binary or n-ary relationship,whether or not to use ISA hierarchies,and whether or not to use aggregation.Ensuring good database design:resulting relational schema should be analyzed and refined further.FD information and normalization techniques are especially useful.第17页/共17页第16页/共17页感谢您的欣赏!第17页/共17页

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > PPT文档

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁