• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
SA Chapter 10
 

SA Chapter 10

on

  • 1,735 views

SA Chapter 10

SA Chapter 10

Statistics

Views

Total Views
1,735
Views on SlideShare
1,730
Embed Views
5

Actions

Likes
0
Downloads
0
Comments
0

2 Embeds 5

http://jujo00obo2o234ungd3t8qjfcjrs3o6k-a-sites-opensocial.googleusercontent.com 4
https://jujo00obo2o234ungd3t8qjfcjrs3o6k-a-sites-opensocial.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    SA Chapter 10 SA Chapter 10 Presentation Transcript

    • Phase 3: System Design- Data Design บทที่ 10
    • Purpose of Database Design (1)
      • Structure the data in stable structures, called normalized tables
        • Not likely to change over time
        • Minimal redundancy
      • Develop a logical database design that reflects actual data requirements
      • Develop a logical database design from which a physical database design can be developed
    • Purpose of Database Design (2)
      • Translate a relational database model into a technical file and database design that balances several performance factors
      • Choose data storage technologies that will efficiently, accurately and securely process database activities
    • Data Modeling แสดงรายละเอียดของข้อมูลในส่วนของ definition, structure และ relationships ซึ่งไม่สามารถแสดงใน Data flow diagrams และ processing logic techniques ที่เรียนไปแล้วในบทก่อน Data Modeling Data modeling มี 3 ระดับได้แก่ conceptual data model, logical data model และ physical file and database.
    • Conceptual Data Modeling
      • Representation of organizational data
      • Purpose is to show rules about the meaning and interrelationships among data
      • Entity-Relationship (E-R) diagrams are commonly used to show how data are organized
      • Main goal of conceptual data modeling is to create accurate E-R diagrams
      • Methods such as interviewing, questionnaires and JAD are used to collect information
      • Consistency must be maintained between process flow, decision logic and data modeling descriptions
    • Process of Conceptual Data Model
      • First step is to develop a data model for the system being replaced
      • Next, a new conceptual data model is built that includes all the requirements of the new system
      • In the design stage, the conceptual data model is translated into a physical design
    • Sample conceptual data model diagram
    • Conceptual Data Model
      • First Deliverables outcome is the entity-relationship diagram which …..
      • Includes the important entities and the relationships among them.
      • No attribute is specified.
      • No primary key is specified.
      • At this level, the data modeler attempts to identify the highest-level relationships among the different entities.
      Deliverables and Outcome (1)
    • Deliverables and Outcome (2)
      • Second deliverable is a set of entries about data objects to be stored in repository or project dictionary
        • Repository links data, process and logic models of an information system
        • Data elements that are included in the DFD must appear in the data model and vise versa
        • Each data store in a process model must relate to business objects represented in the data model
      Conceptual Data Model
    • จะสร้าง conceptual data model ได้อย่างไร ? (Gathering Information for Conceptual Data Modeling)
      • Two perspectives
        • Top-down
          • Data model is derived from an intimate understanding of the business
        • Bottom-up
          • Data model is derived by reviewing specifications and business documents
    • Top-down perspectives (1)
    • INVOICE INVOICE ITEM INVENTORY ITEM PRODUCT ORDER SUPPLIER
        • STOCK ON HAND
        • AMOUNT ADDED
        • INVENTORY LEVELS
        • MINIMUM ORDER QUANTITIES
        • PAYMENTS
      Top-down perspectives (2)
    • INVOICE includes INVOICE ITEM contain INVENTORY ITEM RECIPE PRODUCT request ORDER places SUPPLIER bills Top-down perspectives (3)
    • INVOICE INVOICE ITEM INVENTORY ITEM PRODUCT ORDER SUPPLIER
        • STOCK ON HAND
        • AMOUNT ADDED
        • INVENTORY LEVELS
        • MINIMUM ORDER QUANTITIES
        • PAYMENTS
      Top-down perspectives (2)
    • INVOICE includes INVOICE ITEM contain INVENTORY ITEM RECIPE PRODUCT request ORDER places SUPPLIER bills Supplier_ID Supplier_Name Supplier_Addr Invoice_No Vendor_ID Invoice_date Paid? Amount_added Item_no Item_desc Stock on hand Minimum order Qty Inventory_level Product_ID Product_desc Order_No Order_date Order_Qty Top-down perspectives (4)
    • Practise: Guest (To recognize attributes for entity)
      • Address
      • Arrival Date
      • Family Name
      • GUEST Room Number
      • HOTEL Floor Number
      • ROOM Number of beds
      • STAY Number of parking lots
      • Price
      • TV set available?
    • Practise: Guest
      • Address
      • Arrival Date
      • STAY Family Name
      • GUEST Room Number
      • HOTEL Floor Number
      • ROOM Number of beds
      • Number of parking lots
      • Price
      • TV set available?
    • Bottom-up perspectives (1) PVF CUSTOMER ORDER ORDER NO: 61384 CUSTOMER NO: 1273 NAME: Contempory Designs ADDRESS: 123 Oak St. CITY STATE:-ZIP: Austin,TX28384 ORDER DATE: 21/01/2006 PROMISED DATE: 31/01/2006 PRODUCT NO. DESCRIPTION QTY_ORDERED UNIT PRICE M128 BookCase 4 200.00 B381 Cabinet 2 900.00 R210 Table 1 500.00
    • Bottom-up perspectives (1) PVF CUSTOMER ORDER ORDER NO: 61384 CUSTOMER NO: 1273 NAME: Contempory Designs ADDRESS: 123 Oak St. CITY STATE:-ZIP: Austin,TX28384 ORDER DATE: 21/01/2006 PROMISED DATE: 31/01/2006 PRODUCT NO. DESCRIPTION QTY_ORDERED UNIT PRICE M128 BookCase 4 200.00 B381 Cabinet 2 900.00 R210 Table 1 500.00
    • Bottom-up perspectives (2)
      • ORDER NO
      • ORDER DATE
      • PROMISED DATE
      • UNIT PRICE
      • QUANTITY ORDERED
      • PRODUCT NO
      • DESCRIPTION
      • CUSTOMER NO
      • NAME
      • ADDRESS
      • CITY-STATE-ZIP
      From the form : 1. we determine that the following data must be kept in the database 2. Each order is from one customer 3. An order can have multiple line items, each for one product
    • ORDER CUSTOMER PRODUCT Order_no Order_date Qty_order Promised_date Unit_price Prod_no Cust_no Prod_desc Cust_name Addr City_state places includes
    • กรณีที่ได้ relations จาก หลาย user interface
              • รวม relations ที่ได้ของแต่ละ User Interface ให้เป็น consolidated model
    • จากข้อมูลสรุปที่ได้จากขั้นตอนการวิเคราะห์ระบบ
      • Moonlight coffees is a fast growing chain of high quality coffee shops with currently over 500 shops in 12 countries of the world. Shops are located at first-class locations, such as major shopping, entertainment an business areas, airports, railway stations, museums. Moonlight coffees has some 9,000 employees.
      • Products:
      • All shops serve coffees, teas,soft drinks and various kind of pastries. Most shops sell nonfoods, like postcards and sometimes even theatre tickets.
      • Make a list of entities that you think are important for Moonlight Coffees. Use your imagination and common sense and use what you find in the summary above.
      • COUNTRY PRICE
      • FOOD CURRENCY
      • DRINK STOCK
      • PASTRY DEPARTMENT
      • PRODUCT EXCHANGE RATE
      • LOCATION TYPE
      • EMPLOYEE
      • และข้อมูลจาก business rules ขององค์กรจะทำให้เราเขียนความสัมพันธ์ระหว่าง entity ได้
      การเขียน conceptual data model
      • Logical Data Model
      • Features of logical data model include:
      • Includes all entities and relationships among them.
      • All attributes for each entity are specified.
      • The primary key for each entity specified.
      • Foreign keys (keys identifying the relationship between different entities) are specified.
      • Normalization occurs at this level.
      • At this level, the data modeler attempts to describe the data in as much detail as possible, without regard to how they will be physically implemented in the database.
      • The steps for designing the logical data model are as follows:
      • Identify all entities. ( ใช้ conceptual data model เป็นจุดเริ่มต้น )
      • Specify primary keys for all entities.
      • Find the relationships between different entities.
      • Find all attributes for each entity.
      • Resolve many-to-many relationships.
      • Normalization .
      • เปลี่ยน E-R Diagrams ให้เป็น Relations
    • Relational Database Model
      • Data represented as a set of related tables or relations
      • Relation
        • A named, two-dimensional table of data. Each relation consists of a set of named columns and an arbitrary number of unnamed rows
        • Properties
          • Entries in cells are simple
          • Entries in columns are from the same set of values
          • Each row is unique
          • The sequence of columns can be interchanged without changing the meaning or use of the relation
          • The rows may be interchanged or stored in any sequence
    • Relational Database Model
      • Well-Structured Relation
        • A relation that contains a minimum amount of redundancy and allows users to insert, modify and delete the rows without errors or inconsistencies
    • Normalization
      • The process of converting complex data structures into simple, stable data structures
      The result of normalization is that every non primary key attribute depends upon the whole primary key
    • Steps in Normalization
    • การเปลี่ยน E-R Diagrams ให้เป็น Relations Customer_ID Name C USTOMER Address City_State_ZIP Discount CUSTOMER( Customer_ID ,Name,Address,City_State_ZIP,Discount)
          • แปลง Entities
      • ใช้ชื่อของ Entity เป็นชื่อ Relation
      • แปลง Identifier ของ Entity มาเป็น Primary Key ของ Relation นั้นๆ Primary Key ของ Weak Entity ต้องรวม Primary Key ของ Entity ที่มันไปขึ้นอยู่ด้วยไว้ใน Primary Key ของ Weak Entity ด้วย
      • Attributes ทั้งหมดเป็น non- key attributes
          • 2. แปลง Relationship
          • 2.1 Binary 1:N and 1:1 relationships
      CUSTOMER( Customer_NO ,Name,Address, City_State,ZIP,Discount) ORDER( Order_No ,Order_date,Promised_date,Customer_NO)
      • ถ้าเป็น Binary one-to-many relationship (1:N) ให้เอา attribute หรือ attributes ที่เป็น primary key ของ entity ข้างที่เป็น one ไปเป็น foreign key ของข้างที่เป็น many
      • ถ้าเป็น Binary หรือ Unary one-to-one relationship (1:1) ให้เลือกว่าจะเอา primary key ของ A เพิ่มเป็น Foreign key ของ B หรือเอา primary key ของ B เพิ่มเป็น Foreign key ของ A หรือทำทั้งสองทาง
          • 2.2 Binary and Higher Degree M:N Relationships
      ORDER( Order_number ,Order_date,Promised_date) PRODUCT( Product_ID ,Description,Room,……….) ORDER_LINE( Order_Number,Product_ID ,Quantity_Ordered)
      • Entity A และ Entity B มีความสัมพันธ์แบบ M: N relationship (or associative entity)
      • สิ่งที่ต้องทำในการแปลงคือสร้าง relation ใหม่ (relation C) ให้มี Primary key ที่มาจาก primary key ของทั้ง A และ B
          • 2.3 Unary Relationships
      EMPLOYEE( Emp_ID ,Name,Birthdate,Manager_ID) ITEM(Item_Number,Name,Cost) ITEM_BILL(Item_Number,Component_Number,Quantity)
      • เป็นความสัมพันธ์ระหว่าง Instances ของ entity เดียวกัน (recursive relationships) ใช้หลักการเดียวกันกับที่กล่าวมาแล้วในข้อ 2.1 และ 2.2 และใช้ recursive foreign key
    • Physical Data Model (1)
      • Physical database design results in converting relations into tables
        • Based upon results of logical database design
        • Key decisions
          • Choosing format for each attribute from the logical database model
          • Grouping attributes from the logical database model into physical records/rows
          • 3. Selecting media and structures for storing data to make access more efficient
    • Physical Data Model (2)
          • Design Fields
          • Data Types
              • Coding and Compression Techniques
              • Controlling Data Integrity
              • Null Value control
        • Designing Physical Tables
          • Has two goals : efficient use of secondary storage and data processing speed
          • Whereas Normalization emphasized on well-structured relations.
      Denormalization
    • Data Types (1)
      • Objective of choosing Data type :
      • Minimize storage space
      • Represent all possible values of the field
      • Improve data integrity for the field
      • Support all data manipulations desired on the field
    • Data Types (2) Data Coding : Pros – reduce storage space - increase integrity (by restricting input to only a few values) Cons – more difficult to users to remember - program must be written to decode fields before display
    • Data Types (3) Data Integrity : The value of foreign key CUSTOMER_ID field within a CUST_ORDER must be limited to the set of CUSTOMER_ID values from the CUSTOMER relations. We would not want to accept an order for a non-existing or unknown CUSTOMER.
    • Data Types (4) Default Value : Null Value Control : - distinct from 0 or blank or any other value - indicate that the value of the field is missing or unknown - ต้องกำหนดว่า field ใดเป็น null ไม่ได้
      • Physical Data Model (3)
      • Features of physical data model include:
      • Specification all tables and columns.
      • Foreign keys are used to identify relationships between tables.
      • Denormalization may occur based on user requirements.
      • Physical considerations may cause the physical data model to be quite different from the logical data model.
      • The steps for physical data model design are as follows:
      • Convert entities into tables. .
      • Convert attributes into columns.
      • Modify the physical data model based on physical constraints / requirements.
    • Table Specification Name Description Type Length Value/Range Notes/Remarks Table Name : BankAccount PK : ACCT_NO FK : ACCT_NO เลขที่บัญชี CHAR 7 0-9 Format: nnn-nnnn ธนาคารของลูกค้า Unique Not Null AMOUNT ยอดเงินที่เบิก NUMERIC 5 ,2 0 -10,000 Not Null Must <= BALANCE BALANCE ยอดเงินคงเหลือ ..... ...... ......... ....... ในบัญชี .... ..... .... .... .... ....
      • Normalized Product Relation
      • PRODUCT( Product_ID ,Description,Drawing_Number,Weight,Color,
      • Unit_Cost,Burden_Rate,Price,Product_manager)
      Denormalization The process of splitting or combining normalized relations into physical tables based on affinity of use of rows and fields.
      • Denormalized Product Relation by columns
      • Engineering: E_PRODUCT( Product_ID ,Description,Drawing_Number,
      • Weight,Color)
      • Accounting: A_PRODUCT( Product_ID ,Unit_Cost,Burden_rate)
      • Marketing: M_PRODUCT( Product_ID ,Description,Color,Price,
      • Product_Manager)
      • Normalized Customer Table by rows
      • Denormalized Regional Customer Tables
      Customer_ID Name Region Annual_Sales 1256 Rogers Atlantic 10,000 1323 Temple Pacific 20,000 1455 Gates South 15,000 1626 Hope Pacific 22,000 2433 Bates South 14,000 2566 Bailey Alantic 12,000 Customer_ID Name Region Annual_Sales 1256 Rogers Atlantic 10,000 2566 Bailey Alantic 12,000 A_CUSTOMER Customer_ID Name Region Annual_Sales 1323 Temple Pacific 20,000 1626 Hope Pacific 22,000 P_CUSTOMER Customer_ID Name Region Annual_Sales 1455 Gates South 15,000 2433 Bates South 14,000 S_CUSTOMER
      • Two entities with a one-to-one relationship
      Three common situations where denormalization may be used
        • A Many-to-many relationship (associative entity) with non key attributes
      • Duplication of data – attribute description and excessive updating if duplicated data changes
      • Reference data
      • Several items have the same instructions
      • STORAGE INSTRUCTIONS relate only to ITEM table.
      • Reducing the number of tables to access
      • But creating redundancy and extra data maintenance
    • Business Rules (1) :
      • Specifications that preserve the integrity of data model
      • นักวิเคราะห์ระบบต้องศึกษาข้อมูลเกี่ยวกับ business rules ตั้งแต่ขั้นตอนการวิเคราะห์ระบบงาน (determining requirements)
      • Four basic types of business rules are :
        • Entity integrity – Each instance of an entity type must have a unique identifier that is not null.
        • Referential integrity constraints – Rules concerning the relationships between entity types
        • Domains – Constraints on valid values for attributes
        • Triggering operations – Other business rules that protect the validity of attributes values
    • Business Rules(2) :
    • Designing Controls for Files
      • Backup Techniques
        • Periodic backup of files
        • Transaction log or audit trail (storing a copy of each changes to a log file)
        • Change log (storing a copy of each row before and after it is changed)
      • Data Security Techniques
        • Coding or encrypting
        • User account management
        • Prohibiting users from working directly with the data. Users work with a copy which updates the files only after validation checks
    • Designing Control for files
    •  
    • Exercise ข้อ 1. เขียน sequence dialogue diagram จากจอภาพต่อไปนี้ Welcome Page
      • เมนูหลัก
      • Product Information
      • Rental Information
      Product number verification Screen Product information selection screen New Product Request screen Rental Status screen Rental History screen Rental Extension request screen Extension confirmation screen Enter new product comment screen View comment Inventory review
    • Welcome page Product Information Rental Information Product No Verification Product Selection New Product request Rental status Rental history Enter new Product comment View comment Inventory view Rental extension Extension confirmation 0 3 2 2.1 2.2 2.3 3.1 3.2 2.1.1 2.1.2 2.2.1 3.1.1 3.1.1.1 1 1 2 2 2 2.1 2.2 2.1 3 3 3.1 3.1.1 system 1 เมนูหลัก 0