chapter 7 database design n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 7 Database Design PowerPoint Presentation
Download Presentation
Chapter 7 Database Design

Loading in 2 Seconds...

play fullscreen
1 / 32

Chapter 7 Database Design - PowerPoint PPT Presentation


  • 70 Views
  • Uploaded on

Chapter 7 Database Design. UML Specification for Data Modeling The Relational Data Model and Object Model Persistence Frameworks Database Design. UML Specification for Data Modeling. 7.1 UML Specification for Data Modeling. UML Notation for Data Modeling

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Chapter 7 Database Design' - ingo


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
chapter 7 database design
Chapter 7 Database Design
  • UML Specification for Data Modeling
  • The Relational Data Model and Object Model
  • Persistence Frameworks
  • Database Design
7 1 uml specification for data modeling
7.1 UML Specification for Data Modeling
  • UML Notation for Data Modeling
  • Modeling Associations in the Data Model
  • Modeling Aggregation in the Data Model
  • Modeling Inheritance in the Data Model
modeling associations in the data model

CourseOffering

- number : String

0..*

0..*

Course

- name

1

- description

- number

Modeling Associations in the Data Model
  • Associations between two persistent objects are realized as foreign keys to the associated objects.
    • A foreign key is a column in one table which contains the primary key value of associated object

Course Offering table

Foreign Key

Primary Key

Course table

modeling aggregation in the data model
Modeling Aggregation in the Data Model
  • Aggregation is also modeled using foreign key relationships
    • Using composition implements a cascading delete constraint

Student table

Student.

- studentID : int

Primary Key

1

1

0..*

0..*

Foreign Key

Schedule table

Schedule

- semester : Semester

modeling inheritance in the data model
Modeling Inheritance in the Data Model
  • A data model does not support modeling inheritance in a direct way
  • Two options
    • Use separate tables (normalized data)
    • Duplicate all inherited associations and attributes (de-normalized data)
7 2 the relational data model and object model
7.2 The Relational Data Model and Object Model
  • The Relational Data Model
  • The Object Model
the relational data model
The Relational Data Model
  • The relational model is composed of entities and relations. An entity may be a physical table or a logical projection of several tables also known as a view.
the object model
The Object Model
  • An object model contains classes. Classes define the structure and behavior of a set of objects, sometimes called objects instances. The structure is represented as attributes (data values) and associations (relationships between classes).
7 3 persistence frameworks
7.3 Persistence Frameworks
  • The Purpose of a Persistence Framework
  • Hibernate
hibernate
Hibernate
  • Object / Relational mapping (ORM) and persistence / query framework
    • i.e. It does even more stuff for you!
  • Some features of Hibernate
    • HibernateDaoSupport – superclass, easy HibernateTemplate access
    • Database independence - sits between the database and your java code, easy database switch without changing any code
    • Object / Relational Mapping (ORM) - Allows a developer to treat a database like a collection of Java objects
    • Object 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 to map value objects (POJOs) to database tables
    • Transparent persistence - Allows easy saves/delete/retrieve for simple value objects
    • Very high performance “in general” due to intelligent (2-level) caching, although in a few cases hand-written SQL might beat it
hibernate1
Hibernate
  • Hibernate basically sits between the DB and your code
  • Can map persistent objects to tables
7 4 database design
7.4 Database Design
  • Purpose
  • Overview
  • Steps
  • Map persistent design classes to tables
  • Distribute class behavior to the database
purpose
Purpose
  • To ensure that persistent data is stored consistently and efficiently.
  • To define behavior that must be implemented in the database.
database design overview

Supplementary

Specifications

DesignGuidelines

Data Model

Design Classes

Database Design Overview

Use-Case Realization

Database

Design

steps
Steps
  • Map Persistent Design Classes to the Data Model
  • Optimize the Data Model for Performance
  • Optimize Data Access
  • Define Storage Characteristics
  • Define Reference Tables
  • Define Data and Referential Integrity Enforcement Rules
  • Distribute Class Behavior to the Database
  • Review the Results
mapping persistent classes to tables
Mapping Persistent Classes to Tables
  • In a relational database
    • Every row is regarded as an object
    • A column in a table is equivalent to a persistent attribute of a class

Attributes from object type

Object Instance

map class behavior to stored procedures
Map Class Behavior to Stored Procedures
  • Determine if any operations can be implemented as a stored procedure
  • Candidate operations
    • Deal with persistent data
    • Any operations where a query is involved in a computation
    • Need to access the database to validate data
what are stored procedures
What Are Stored Procedures?
  • A stored procedure is executable code which runs under the RDBMS
  • Two types of stored procedures
    • Procedures: Executed explicitly by an application
    • Triggers: Invoked implicitly when some database event occurs
example map class behavior to stored procedures
Example: Map Class Behavior to Stored Procedures

Class

Candidate Operations

  • getTuition
  • addSchedule
  • getSchedule
  • deleteSchedule
  • getStudentID
  • getName
  • getAddress