Presentation is loading. Please wait.

Presentation is loading. Please wait.

DATABASE APPLICATION DEVELOPMENT SAK 3408

Similar presentations


Presentation on theme: "DATABASE APPLICATION DEVELOPMENT SAK 3408"— Presentation transcript:

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

2 REMEMBER Best: Spend your time on design and SQL. Worst:
Program Best: Spend your time on design and SQL. Design SQL Program Worst: Compensate for poor design and limited SQL with programming. SAK3408 by PSS (W2)

3 Database System Design
User views of data. Conceptual data model. Implementation (relational) data model. Physical data storage. 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. SAK3408 by PSS (W2)

4 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 SAK3408 by PSS (W2)

5 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. SAK3408 by PSS (W2)

6 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 SAK3408 by PSS (W2)

7 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. SAK3408 by PSS (W2)

8 Design Stages Physical Design Initiation Table definitions Scope
Application development Queries Forms Reports Application integration Data storage Security Procedures Implementation Training Purchases Data conversion Installation Evaluation & Review 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 SAK3408 by PSS (W2)

9 Overview of Database Design Process
REQUIREMENTS COLLECTION & ANALYSIS Functional Requirements Data requirement FUNCTIONAL ANALYSIS CONCEPTUAL DESIGN High-Level Transaction Specification Conceptual Schema DBMS-independent DBMS-specific LOGICAL DESIGN (DATA MODEL MAPPING) APPLICATION PROGRAM DESIGN Logical Schema In the data model of specific DBMS TRANSACTION IMPLEMENTATION PHYSICAL DESIGN Application Program Internal Schema SAK3408 by PSS (W2)

10 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. SAK3408 by PSS (W2)

11 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. Pet Store Examples Entity: Customer, Merchandise, Sales Class: Customer, Merchandise, Sale Object: Joe Jones, Premium Cat Food, Sale #32 Property: LastName, Description, SaleDate Method: AddCustomer, UpdateInventory, ComputeTotal Association: Each Sale can have only one Customer. SAK3408 by PSS (W2)

12 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 SAK3408 by PSS (W2)

13 Guideline Data Names Relate to business – customer \ File10
Be meaningful – avoid is, it, has Be unique – homeadd, campusadd Repeatable–studbirthdate, stafbirthdate SAK3408 by PSS (W2)

14 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. SAK3408 by PSS (W2)

15 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 SAK3408 by PSS (W2)

16 E-R Model Constructs Entity Attribute Relationship SAK3408 by PSS (W2)

17 Basic E-R Notation A special entity that is also a relationship
Entity symbols Attribute symbols Relationship symbols SAK3408 by PSS (W2)

18 Figure 2.3 Sample E-R Diagram
SAK3408 by PSS (W2)

19 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 SAK3408 by PSS (W2)

20 Entity Type vs. Entity Instance
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. SAK3408 by PSS (W2)

21 Entity Type vs. Entity Instance (cont.)
Entity Type : EMPLOYEE Attribut : EMP_NUM CHAR(10) NAME CHAR(25) STATE CHAR(35) 2 instances of EMPLOYEE : Ali Amir Perak Kedah SAK3408 by PSS (W2)

22 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. SAK3408 by PSS (W2)

23 Figure 2.10 Strong and weak entities
Identifying relationship Strong entity Weak entity SAK3408 by PSS (W2)

24 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. SAK3408 by PSS (W2)

25 Example SAK3408 by PSS (W2)

26 Simple vs. Composite Attribute
Simple attribute – cannot broken into smaller components Composite attribute – can broken into component parts SAK3408 by PSS (W2)

27 Simple key attribute The key is underlined SAK3408 by PSS (W2)

28 a) Composite attribute
An attribute broken into component parts SAK3408 by PSS (W2)

29 b) Composite key attribute
The key is composed of two subparts SAK3408 by PSS (W2)

30 Single-Valued vs. Multivalued Attribute
Single-Valued – each of the attributes has one value Multivalued – attribute more than one value SAK3408 by PSS (W2)

31 Entity with a multivalued attribute (Skill)
an employee can have more than one skill SAK3408 by PSS (W2)

32 Stored vs. Derived Attributes
Stored attribute – data input or set Derived Attribute – attribute whose values can be calculated from related attribute values. SAK3408 by PSS (W2)

33 Entity with a derived attribute (Years_Employed)
from date employed and current date SAK3408 by PSS (W2)

34 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 SAK3408 by PSS (W2)

35 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 SAK3408 by PSS (W2)

36 Ex: identifier The key is composed of two subparts SAK3408 by PSS (W2)

37 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 SAK3408 by PSS (W2)

38 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 SAK3408 by PSS (W2)

39 Figure 2.6 (a) Relationship type
Figure 2.6 (b) Entity and Relationship instances SAK3408 by PSS (W2)

40 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 SAK3408 by PSS (W2)

41 Degree of Relationships
Degree of a Relationship is the number of entity types that participate in it Unary Relationship Binary Relationship Ternary Relationship SAK3408 by PSS (W2)

42 Figure 2.7 Degree of relationships
Entities of two different types related to each other One entity related to another of the same entity type Entities of three different types related to each other SAK3408 by PSS (W2)

43 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 SAK3408 by PSS (W2)

44 Figure 2.8 Degree of relationships and Cardinality
(a) Unary relationships SAK3408 by PSS (W2)

45 (b) Binary relationships
SAK3408 by PSS (W2)

46 (c) Ternary relationships
Note: a relationship can have attributes of its own SAK3408 by PSS (W2)

47 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 SAK3408 by PSS (W2) 29

48 Figure 2.8 Cardinality Mandatory and Optional
SAK3408 by PSS (W2) 8

49 Figure 2.9 Cardinality Constraints
(a) Basic relationship with only maximum cardinalities showing (b) Mandatory minimum cardinalities SAK3408 by PSS (W2)

50 Figure 2.10 Examples of multiple relationships
Employees and departments – entities can be related to one another in more than one way SAK3408 by PSS (W2)

51 SAK3408 by PSS (W2)

52 Strong vs. Weak Entities, and Identifying 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 SAK3408 by PSS (W2)

53 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 SAK3408 by PSS (W2)

54 Figure 2.11 An associative entity
(a) An associative entity (CERTIFICATE) 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 SAK3408 by PSS (W2) 21

55 (b)Ternary relationship as an associative entity
SAK3408 by PSS (W2) 36

56 Components of E-R Model
SAK3408 by PSS (W2)

57 Recalled : Teaching Plan W2
Database design stages Conceptual data model Unified Modeling Language Entity Relationship Diagram (ERD) SAK3408 by PSS (W2)


Download ppt "DATABASE APPLICATION DEVELOPMENT SAK 3408"

Similar presentations


Ads by Google