+ All Categories
Home > Documents > DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

Date post: 21-Dec-2015
Category:
View: 225 times
Download: 1 times
Share this document with a friend
Popular Tags:
57
DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)
Transcript
Page 1: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

DATABASE APPLICATION DEVELOPMENTSAK 3408

Database Design I(week 2)

Page 2: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

REMEMBER

Des

ign

SQ

L

Pro

gram

Best:

Spend your time

on design and SQL.Des

ign

SQ

L

Pro

gram

Worst:Compensate for poor designand limited SQL with programming.

Page 3: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Database System Design

User viewsof data.

Conceptualdata model.

Customer(CustomerID, Name, Address, …)

SalesPerson(EmployeeID, Name, Commission, … )

Order(OrderID, OrderDate, CustomerID, EmployeeID, … )

OrderItem(OrderID, ItemID, Quantity, Price, … )

Item(ItemID, Description, ListPrice, …)

Implementation(relational)data model.

Physicaldatastorage.

Class diagram that shows business entities, relationships, and rules.

List of nicely-behaved tables. Use data normalization to derive the list.

Indexes and storage methods to improve performance.

Page 4: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

The Need for Design Goal: To produce an information system

that adds value for the user Reduce costs Increase sales/revenue Provide competitive advantage

Objective: To understand the system To improve it To communicate with users and IT staff

Methodology: Build models of the system

Page 5: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Designing Systems

Designs are a model of existing & proposed systems They provide a picture or

representation of reality They are a simplification Someone should be able to read your

design (model) and describe the features of the actual system.

Page 6: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

How to builds your model?

You build models by talking with the users Identify processes Identify objects Determine current problems and future

needs Collect user documents (views)

Break complex systems into pieces and levels

Page 7: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Initial Steps of Design

1. Identify the exact goals of the system.

2. Talk with the users to identify the basic forms and reports.

3. Identify the data items to be stored.

4. Design the classes (tables) and relationships.

5. Identify any business constraints.

6. Verify the design matches the business rules.

Page 8: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Design Stages

Initiation Scope Feasibility Cost & Time estimates

Requirements Analysis User Views & Needs

Forms Reports

Processes & Events Objects & Attributes

Conceptual Design Models

Data flow diagram Entity Relationships Objects

User feedback

Physical Design Table definitions Application development

Queries Forms Reports Application integration

Data storage Security Procedures

Implementation Training Purchases Data conversion Installation

Evaluation & Review

Page 9: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Overview of Database Design Process

REQUIREMENTS COLLECTION & ANALYSIS

Data requirement

CONCEPTUAL DESIGN

Conceptual Schema

LOGICAL DESIGN(DATA MODEL MAPPING)

Logical SchemaIn the data model of specific DBMS

PHYSICAL DESIGN

Internal Schema

Functional Requirements

FUNCTIONAL ANALYSIS

APPLICATION PROGRAM DESIGN

TRANSACTION IMPLEMENTATION

High-Level Transaction Specification

Application Program

DBMS-independentDBMS-specific

Page 10: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Unified Modeling Language (UML)

A relatively new method to design systems.Contains several types of diagrams:

Contains several types of diagrams:

The class diagram is the most important for database design.

Page 11: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Definitions

Entity: Something in the real world that we wish to describe or track.

Class: Description of an entity, that includes its attributes (properties) and behavior (methods).

Object: One instance of a class with specific data.Property: A characteristic or descriptor of a class or entity.Method: A function that is performed by the class.Association: A relationship between two or more classes.

Entity: Customer, Merchandise, SalesClass: Customer, Merchandise, SaleObject: Joe Jones, Premium Cat Food, Sale #32Property: LastName, Description, SaleDateMethod: AddCustomer, UpdateInventory, ComputeTotalAssociation: Each Sale can have only one Customer.

Pet Store Examples

Page 12: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Business Rule

BR are important in data modelling because they govern how data are – handled and stored.

Basic BR : Data names Data definition

Names and definition must provide for : Entity types Attribute Relationship

Page 13: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Guideline Data Names

Relate to business – customer \ File10

Be meaningful – avoid is, it, has Be unique – homeadd, campusadd Repeatable–studbirthdate,

stafbirthdate

Page 14: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Data Definition

“ A course is a module of instruction in a particular area.”

“A customer may request a model car from a rental branch in a particular date.”

Guideline : A definition will state such characteristics of

the data objects. Whether the data is singular or plural Who determine the value for the data Whether data is static or changes over time Whether the data is optional or an empty Where, when and how data is created.

Page 15: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

The E-R Model

E-R model – a logical representation of the data for an organization or for a business area

E-R diagram – a graphical representation of an entity-relationship model

Page 16: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

E-R Model Constructs

EntityAttributeRelationship

Page 17: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Basic E-R Notation

Entity symbols

Relationship symbols

Attribute symbols

A special entity that is also a relationship

Page 18: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Figure 2.3 Sample E-R Diagram

Page 19: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Entity

An entity is a person, place, object, event or concept in the user environment about which the organization wishes to maintain data.

Ex: Person – EMPLOYEE, STUDENT, PATIENT Place – STORE, WAREHOUSE, STATE Object – MACHINE, BUILDING, AUTOMOBILE Event – SALE, REGISTRATION, RENEWAL Concept – ACCOUNT, COURSE

Entity type, entity instances, strong entity, weak entity

Page 20: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Entity Type vs. Entity Instance

Entity Type Share common characteristic Given a name (CAPITAL LETTER) Rectangle Collection of entities (often corresponds to a

table). Ex: EMPLOYEE

Entity Instances a single occurrence of an entity type (often

corresponds to a row in a table) Ex: may be 100 of instances of entity

EMPLOYEE stored in database.

Page 21: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Entity Type vs. Entity Instance (cont.)

Entity Type : EMPLOYEE

Attribut : EMP_NUM CHAR(10)NAME CHAR(25)STATE CHAR(35)

2 instances of EMPLOYEE :00123 02345Ali AmirPerak Kedah

Page 22: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Strong vs. Weak Entity Types

Strong Entity Type entity that exists independently of other entity

types Unique characteristic Called an identifier Ex: STUDENT, EMPLOYEE

Weak Entity Type entity type whose existence depends on

some other entity type No meaning in ERD without strong entity.

Page 23: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Figure 2.10 Strong and weak entities

Strong entity Weak entityIdentifying relationship

Page 24: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Attribute property or characteristic of an entity

type (often corresponds to a field in a table)

Ex: entity type – STUDENT Attributes – name, add, id, program

Simple att vs composite att. Single-valued att vs multivalued att Stored att vs derived att Identifier att.

Page 25: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Example

Page 26: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Simple vs. Composite Attribute

Simple attribute – cannot broken into smaller components

Composite attribute – can broken into component parts

Page 27: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Simple key attribute

The key is underlined

Page 28: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

a) Composite attribute

An attribute broken into component parts

Page 29: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

b) Composite key attribute

The key is composed of two subparts

Page 30: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Single-Valued vs. Multivalued Attribute

Single-Valued – each of the attributes has one value

Multivalued – attribute more than one value

Page 31: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Entity with a multivalued attribute (Skill)

Multivalued: an employee can have more than one skill

Page 32: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Stored vs. Derived Attributes

Stored attribute – data input or set

Derived Attribute – attribute whose values can be calculated from related attribute values.

Page 33: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Entity with a derived attribute (Years_Employed)

Derived from date employed and current date

Page 34: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Identifiers (Keys)

Identifier (Primary Key) - An attribute (or combination of attributes) that uniquely identifies individual instances of an entity type

Composite Identifier – an identifier that consists of a composite attribute.

Candidate Key – an attribute that could be a key…satisfies the requirements for being a key

Page 35: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Characteristics of Identifiers

Will not change in value Will not be null No intelligent identifiers (e.g.

containing locations or people that might change)

Substitute new, simple keys for long, composite keys

Page 36: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Ex: identifier

The key is composed of two subparts

Page 37: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Relationship

Relationship link between entities (corresponds to

primary key-foreign key equivalencies in related tables)

Relationship Types vs. Relationship Instances The relationship type is modeled as the

diamond and lines between entity types…the instance is between specific entity instances

Page 38: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Relationships (cont.)

Relationship Types vs. Relationship Instances

The relationship type is modeled as the diamond and lines between entity types…the instance is between specific entity instances

Page 39: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Figure 2.6 (a) Relationship type

Figure 2.6 (b) Entity and Relationship instances

Page 40: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Relationships (cont.)

Relationships can have attributes These describe features pertaining to the

association between the entities in the relationship

Two entities can have more than one type of relationship between them (multiple relationships)

Associative Entity = combination of relationship and entity

Page 41: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Degree of Relationships Degree of a Relationship is the

number of entity types that participate in it Unary Relationship Binary Relationship Ternary Relationship

Page 42: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Figure 2.7 Degree of relationships

One entity related to another of the same entity type

Entities of two different types related to each other

Entities of three different types related to each other

Page 43: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Cardinality of Relationships

One – to – One Each entity in the relationship will have

exactly one related entity One – to – Many

An entity on one side of the relationship can have many related entities, but an entity on the other side will have a maximum of one related entity

Many – to – Many Entities on both sides of the relationship can

have many related entities on the other side

Page 44: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Figure 2.8 Degree of relationships and Cardinality(a) Unary relationships

Page 45: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

(b) Binary relationships

Page 46: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

(c) Ternary relationships

Note: a relationship can have attributes of its own

Page 47: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Cardinality Constraints

Cardinality Constraints - the number of instances of one entity that can or must be associated with each instance of another entity.

Minimum Cardinality If zero, then optional If one or more, then mandatory

Maximum Cardinality The maximum number

Page 48: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Figure 2.8 Cardinality Mandatory and Optional

Page 49: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

(a) Basic relationship with only maximum cardinalities showing

(b) Mandatory minimum cardinalities

Figure 2.9 Cardinality Constraints

Page 50: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Employees and departments – entities can be related to one another in more than one way

Figure 2.10 Examples of multiple relationships

Page 51: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Page 52: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Strong vs. Weak Entities, andIdentifying Relationships

Strong entities exist independently of other types of entities has its own unique identifier represented with single-line rectangle

Weak entity dependent on a strong entity…cannot exist on its

own Does not have a unique identifier represented with double-line rectangle

Identifying relationship links strong entities to weak entities represented with double line diamond

Page 53: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Associative Entities

It’s an entity – it has attributes

AND it’s a relationship – it links entities together When should a relationship with attributes instead be an

associative entity? All relationships for the associative entity should be many The associative entity could have meaning independent of

the other entities The associative entity preferably has a unique identifier,

and should also have other attributes The associative may be participating in other relationships

other than the entities of the associated relationship Ternary relationships should be converted to associative

entities

Page 54: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Figure 2.11 An associative entity

Associative entity involves a rectangle with a diamond inside.Note that the many-to-many cardinality symbols face toward the associative entity and not toward the other entities

(a) An associative entity (CERTIFICATE)

Page 55: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

(b)Ternary relationship as an associative entity

Page 56: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Components of E-R Model

Page 57: DATABASE APPLICATION DEVELOPMENT SAK 3408 Database Design I (week 2)

SAK3408 by PSS (W2)

Recalled : Teaching Plan W2

Database design stages Conceptual data model Unified Modeling Language Entity Relationship Diagram (ERD)


Recommended