gama ilp course ware sdlc data base design new

Upload: dipin-m-varghese

Post on 07-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    1/33

    Data Base Design

    UST Global

    120 Vantis AlisoViejo CA 92656Phone: (949) 716-8757www.ust-global.com

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    2/33

    2

    Concepts of Database Designing

    Database Designing is the process of convertingSystem Requirements to a database model.

    A typical database design lifecycle constitutes thefollowing

    1. Conceptual Modeling Data Flow Diagrams

    2. Logical Modeling ER Diagrams

    Data Dictionary

    Normalization First NF

    Second NF

    Third NF

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    3/33

    3

    Concepts of Database Designing Contd..

    3.Physical Database Design Storage Designing

    Logical Storage

    Physical Storage

    Data Flow Design

    Data Integrity Referential Integrity

    Rules and Constraints

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    4/33

    4

    To document the business informationrequirements

    To identify reuse requirements andopportunities

    To document data requirements basedfunctional activity and/or business rules

    To assist in identification of redundantprocesses

    To guide and support consistent dataadministration

    Purpose of Database Modeling

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    5/33

    5

    Logical Designing

    Any system has or should satisfy a fewimportant characteristics. They are: A well defined system boundary

    A well defined set of inputs and outputs

    A data store that stores information

    Logical Designing is the process of creatingthe logical architecture of a system. Thelogical architecture comprises of defining thelogical components that influence the

    system like processes, data flow, entities etc.

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    6/33

    6

    Logical Designing Contd..

    Following are the various approaches thatare being used as part of the designingprocess. Data Flow Diagrams

    Entity Relationship Diagrams

    Data Dictionary

    Decision Tables and Decision Trees

    State Transition Diagrams

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    7/33

    Entity Relationship Diagrams (ERD)

    While Data Flow Diagrams show the

    flow of data between processes, Entity

    Relationship diagrams show the

    relationship between data. An ER diagram is an effective tool to

    demonstrate and document the data

    relationships which helps bettermanagement and maintenance of data.

    7

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    8/33

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    9/33

    ERD

    Attribute An Attribute is a property that explainsan entity.

    Relationship A Relationship is a definition on theassociation or interaction between Entities

    We can classify Relationships according to twocharacteristics

    Optionality

    Mandatory Relationship

    Optional Relationship

    Cardinality One-to-One

    One-to-Many

    Many-to-Many

    9

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    10/33

    10

    ERD - Notation

    Data Element

    Relationship

    Associated Object

    Cardinality Exactly one

    Cardinality Zero or one

    Cardinality Mandatory Many

    Cardinality Optional Many

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    11/33

    11

    Developing an ERD

    Developing an ERD requires an

    understanding of the system and its

    components.

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    12/33

    12

    How do we start an ERD?

    1. Define Entities: these are usually nouns

    used in descriptions of the system, in the

    discussion of business rules, or in

    documentation; identified in the narrative2. Define Relationships: these are usually

    verbs used in descriptions of the system or

    in discussion of the business rules (entity

    ______ entity); identified in the narrative

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    13/33

    13

    How do we start an ERD? Contd..

    3. Add attributes to the relations; these are

    determined by the queries, and may also

    suggest new entities, e.g. grade; or they

    may suggest the need for keys or identifiers4. Add cardinality to the relations; Many-to-

    Many must be resolved to two One-to-Many

    using an additional entity. Usually

    automatically happens. Sometimes involvesintroduction of a link entity (which will be all

    foreign key) Examples: Patient-Drug

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    14/33

    14

    How do we start an ERD? Contd..

    5. This flexibility allows us to consider a variety

    of questions such as:

    Which beds are free?

    Which assistants work forDr. X?

    What is the least expensive prescription?

    How many doctors are there in the

    hospital? Which patients are family related?

    6. Represent that information with symbols

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    15/33

    ER Diagram Examples

    In a company, each division is managed by only one manager and eachmanager manages only one division

    15

    In a college, every student takes as many courses and every course is taken bymany students

    Among the mobile manufacturing companies, a company manufactures manycars, but a given car is manufactured in only one company

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    16/33

    Data Dictionary

    A Data Dictionary is an organized documentation ofData Elements, Data Structures and Data Flows.

    Data Element - Piece of data, which cannot bedecomposed further in the current context of the

    system. Examples are purchase_order_no,employee_name, interest_rate, etc.

    Data Structure - Composed of data elements or otherdata structures. Examples are Customer_details,which may be composed ofCustomer_name and

    Customer_address. Data Flow is composed of data structures and/or

    data elements. Definitions of dependent datastructures/data elements precede the definition ofdata flow. While defining the data flow the

    connecting points should be mentioned.16

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    17/33

    Transition from Logical to Physical

    17

    Logical Physical

    Data Entities Tables

    Attributes Columns/Fields

    Entity Instances Rows/Records

    Relationships/Cardinality Primary/Foreign Keys

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    18/33

    Database Normalization

    Database Normalization is the process of efficiently organizing data to achievethe following goals

    Avoid data redundancy

    Ensure data integrity.

    There are multiple levels of normalization. A typical application databaseshould be ideally at the 3rd normal form

    First Normal Form

    A relation R is in first normal form (1NF) if and only if all underlyingdomains contain atomic values only.

    Remove redundant columns

    Primary Key

    Second Normal Form

    A relation R is in second normal form (2NF) if and only if it is in 1NF and

    every nonkey attribute is fully dependent on the primary key. Enforce primary key-foreign key relationship

    Third Normal Form

    A relation R is in third normal form (3NF) if and only if it is in 2NF and everynonkey attribute is nontransitively dependent on the primary key.

    18

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    19/33

    First Normal Form (1NF)

    There are no repeating or duplicate

    fields.

    Each cell contains only a single value.

    Each record is unique.

    Identified by primary key

    19

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    20/33

    Example

    Table is not in first normal form

    because:

    Multiple items in color field

    Duplicate records / no primary key

    20

    Item Colors Price Tax

    T-shirt Red, blue 12.00 0.60

    Polo Red, yellow 12.00 0.60

    T-shirt Red, blue 12.00 0.60

    Sweatshirt Blue, black 25.00 1.25

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    21/33

    Example

    Item Color Price Tax

    T-shirt Red 12.00 0.60

    T-shirt Blue 12.00 0.60

    Polo Red 12.00 0.60

    Polo Yellow 12.00 0.60Sweatshirt Blue 25.00 1.25

    Sweatshirt Black 25.00 1.25

    21

    Table is now in first normal form

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    22/33

    Second Normal Form (2NF)

    All non-key fields depend on all

    components of the primary key.

    Guaranteed when primary key is a single

    field.

    22

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    23/33

    Example

    Item Color Price Tax

    T-shirt Red 12.00 0.60

    T-shirt Blue 12.00 0.60

    Polo Red 12.00 0.60

    Polo Yellow 12.00 0.60Sweatshirt Blue 25.00 1.25

    Sweatshirt Black 25.00 1.25

    23

    Table is not in second normal formbecause

    Price and Tax depend on item, but not

    color

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    24/33

    Example

    Item Color

    T-shirt Red

    T-shirt Blue

    Polo Red

    Polo YellowSweatshirt Blue

    Sweatshirt Black

    Item Price Tax

    T-shirt 12.00 0.60

    Polo 12.00 0.60

    Sweatshirt 25.00 1.25

    24

    Tables are now in second normal form

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    25/33

    Third Normal Form (3NF)

    No non-key field depends upon

    another.

    All non-key fields depend only on the

    primary key.

    25

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    26/33

    Example

    Item Color

    T-shirt Red

    T-shirt Blue

    Polo Red

    Polo YellowSweatshirt Blue

    Sweatshirt Black

    Item Price Tax

    T-shirt 12.00 0.60

    Polo 12.00 0.60

    Sweatshirt 25.00 1.25

    26

    Tables are not in third normal formbecause

    Tax depends on price, not item

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    27/33

    Example

    Item Color

    T-shirt Red

    T-shirt Blue

    Polo Red

    Polo Yellow

    Sweatshirt Blue

    Sweatshirt Black

    Item Price

    T-shirt 12.00

    Polo 12.00

    Sweatshirt 25.00

    Price Tax

    12.00 0.60

    25.00 1.25

    27

    Tables are now in third normal form

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    28/33

    Relationships

    Relationships are created between tablesusing the primary key field and a foreign keyfield

    One to One Relationship - One record in atable relates to one record in another table

    One to Many Relationship - One record in atable can relate to many records in anothertable

    Many to Many Relationship - Many records inone table can relate to many records inanother table

    28

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    29/33

    Relationships in the Example

    Item Color

    T-shirt Red

    T-shirt Blue

    Polo Red

    Polo Yellow

    Sweatshirt Blue

    Sweatshirt Black

    Item Price

    T-shirt 12.00

    Polo 12.00

    Sweatshirt 25.00

    Price Tax

    12.00 0.60

    25.00 1.25

    29

    One-to-one

    One-to-many

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    30/33

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    31/33

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    32/33

    Database Integrity

    Primary Key

    Clustered

    Non-Clustered

    Foreign key

    Rules and Constraints

    Check

    Defaults

    Triggers

    32

  • 8/6/2019 GAMA ILP Course Ware SDLC Data Base Design New

    33/33

    Thank you!!