软件需求分析英文课件:Chap 6 - Database Design_第1页
软件需求分析英文课件:Chap 6 - Database Design_第2页
软件需求分析英文课件:Chap 6 - Database Design_第3页
软件需求分析英文课件:Chap 6 - Database Design_第4页
软件需求分析英文课件:Chap 6 - Database Design_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

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

文档简介

1、Chapter 6 Database Design The Relational Data Model and Object Model Persistence Frameworks Database DesignThe Relational Data Model and Object Model6.1 The Relational Data Model and Object Model The Relational Data Model The Object ModelThe Relational Data Model ORDERLINE ITEMPRODUCTOrder_IdLineIte

2、m_IdDescriptionPriceQuantityProduct_IdOrder_IdProduct_IdNamePricelineItemorderproductslineItemsRelationColumnsEntityRelational model is composed of EntitiesAn entity may be a physical table or a logical projection of several tables also known as a view.RelationsThe Object ModelThe Object Model is co

3、mposed of Classes (attributes)AssociationsLineItem- quantity : Integer- number : Integer1.*+lineItemsOrder- number : Integer+orderProduct- number : Integer- description : String- unitPrice : Double1Software Product- version : DoubleHardware Product- assembly : StringRDBMS and Object Orientation are

4、not entirely compatibleRDBMS Focus is on dataBetter suited for ad-hoc relationships and reporting applicationExpose data (column values)Object Oriented systemFocus is on behaviorBetter suited to handle state-specific behavior where data is secondaryHide data (encapsulation)Relational Databases and O

5、bject OrientationThe Persistence Frameworks 6.2 Persistence Frameworks Persistence Framework HibernatePersistence FrameworksThe challenge:Changes should not break the modelThe solution: An object-relational framework thatEncapsulates the physical data storeProvides object translation servicesThe imp

6、ortance of the framework30% of development time is spent in accessing an RDBMSMaintenance can be 60% of total costBusiness Object ModelRelational DatabaseCompact interfacesObject-relational translationEncapsulates data storeHibernate Object / Relational mapping (ORM) and persistence / query framewor

7、ki.e. It does even more stuff for you!Some features of HibernateHibernateDaoSupport superclass, easy HibernateTemplate accessDatabase independence - sits between the database and your java code, easy database switch without changing any codeObject / Relational Mapping (ORM) - Allows a developer to t

8、reat a database like a collection of Java objectsObject oriented query language (HQL) - *Portable* query language, supports polymorphic queries etc.You can also still issue native SQL, and also queries by “Criteria” (specified using “parse tree” of Java objects)Hibernate Mapping - Uses HBM XML files

9、 to map value objects (POJOs) to database tables Transparent persistence - Allows easy saves/delete/retrieve for simple value objectsVery high performance “in general” due to intelligent (2-level) caching, although in a few cases hand-written SQL might beat itHibernateHibernate basically sits betwee

10、n the DB and your codeCan map persistent objects to tablesDatabase Design6.3 Database Design Purpose Overview Steps Map persistent design classes to tables Modeling Associations in the Data Model Modeling Aggregation in the Data Model Modeling Inheritance in the Data Model Distribute class behavior

11、to the databasePurpose To ensure that persistent data is stored consistently and efficiently. To define behavior that must be implemented in the database. Database Design OverviewSupplementarySpecificationsDatabaseDesignUse-Case RealizationDesignGuidelinesData ModelMapping Persistent Classes to Tabl

12、esIn a relational databaseEvery row is regarded as an objectA column in a table is equivalent to a persistent attribute of a classNameStudent_IDThomas Stuart123456Object InstanceAttributes from object typeModeling Associations in the Data Model Associations between two persistent objects are realize

13、d as foreign keys to the associated objects.A foreign key is a column in one table which contains the primary key value of associated objectNumberCourse_ID678456789NameDescriptionNumberMath 101Algebra456789Course Offering tableCourse tableCourse- name- description- numberCourseOffering- number : Str

14、ing 0.*0.*1Primary KeyForeign KeyModeling Aggregation in the Data ModelAggregation is also modeled using foreign key relationshipsUsing composition implements a cascading delete constraintStudent.- studentID : intSchedule- semester : Semester0.*10.*1Student_IDSemester123456Spring 2001Schedule tableS

15、tudent_ID123456Foreign KeyPrimary KeyStudent tableModeling Inheritance in the Data ModelA data model does not support modeling inheritance in a direct wayTwo optionsUse separate tables (normalized data)Duplicate all inherited associations and attributes (de-normalized data)Modeling Inheritance in th

16、e Data Model - ExampleModeling Inheritance in the Data Model - ExampleModeling Inheritance in the Data Model - ExampleMap Class Behavior to Stored ProceduresDetermine if any operations can be implemented as a stored procedureCandidate operationsDeal with persistent data Any operations where a query

17、is involved in a computationNeed to access the database to validate dataWhat Are Stored Procedures?A stored procedure is executable code which runs under the RDBMSTwo types of stored proceduresProcedures: Executed explicitly by an applicationTriggers: Invoked implicitly when some database event occursExample: Map Class Behavior to Stored ProceduresClass

温馨提示

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

评论

0/150

提交评论