ITN MySQL Database Programming 1 Lecture 3 :Database Analysis and Design (I) ITN 170 MySQL Database Programming
ITN MySQL Database Programming 2 Objectives Understand the phases of the Database Development Process Explain what Conceptual Data Modeling and Database Design
ITN MySQL Database Programming 3 Business Requirements Operational System There is 6-steps Development cycle beginning from Business Requirements to Operational System. Data modeling and database design support the first 3 steps of the whole Development cycle. STRTATEGY ANALYSIS DESIGN TRANSITION PRODUCTION BUILD USER DOCUMENTATION
ITN MySQL Database Programming 4 Business Requirements Operational System STRTATEGY ANALYSIS The user and system requirements are gathered and analyzed. The expected information from this step would be a set of requirements that specify the whats of the system and user. A project plan and development time frame are specified at this time. (the documents are outlined and overview are provided) Step 1 & step 2: whats
ITN MySQL Database Programming 5 Business Requirements Operational System STRTATEGY ANALYSIS DESIGN The user requirements and system specifications are applied to create a design document consisting of an entity relationship diagram (ERD), flow charts, and so forth. The purpose of the design step is to convey the hows of the project. Programming languages (eg. SQL), Database Management Systems (eg. MySQL), coding, and naming standards are specified here. Step 3 (an important part): hows whats
ITN MySQL Database Programming 6 Business Requirements Operational System DOCUMENTATION STRTATEGY ANALYSIS DESIGN BUILD The design is converted from specifications and diagrams to actual executables and database structures. During this step, the as-built documents are written; these documents instruct users how to use the system and instruct production support how to support the application. ERDs are mapped to tables, columns, and relations. Step 4:
ITN MySQL Database Programming 7 Business Requirements Operational System STRTATEGY ANALYSIS DESIGN BUILD USER DOCUMENTATION The application is put through user-acceptance testing. This step could go back to any step up to Strategy Database memory usage and I/O balance, as well as contention tuning (DBA’s task). User may need to update their systems or modify their strategies (if system crashes). TRANSITION Stage 5:
ITN MySQL Database Programming 8 Business Requirements Operational System STRTATEGY ANALYSIS DESIGN BUILD USER DOCUMENTATION The project is passed off to production support and moves into a maintenance mode in which code is locked down and database changes are minimized. Once a project is in production, the activities around it move into the support and maintenance area. Usually there is no need to change the database structures because the transition testing stage is done. TRANSITION PRODUCTION Stage 6:
ITN MySQL Database Programming 9 Database Development Process Business Requirements Operational System Database development is a top-down, systematic approach that transforms business information requirements into an operational database. Analysis Design Build Strategy Entity-Relationship Data Model Entity Definitions Table Definitions Index, View, and Cluster Definitions Conceptual Data Modeling Database Design Database Build
ITN MySQL Database Programming 10 Database Development Process The Database Development Process is a vertical Development Cycle which has been successfully used and developed as an industry- standard since 1980’s. Business Requirements Operational System Analysis Design Build Strategy Conceptual Database Logical Database Conceptual Data Modeling Database Design Database Build Physical Database
ITN MySQL Database Programming 11 Business Information Requirements Top-down database development begins with the information requirements of the business. " I manage the Human Resources Department for a large company. We need to keep information about each of our company's employees. We need to track each employee's at first name, last name, job or position, hire date, and salary. For any employees on commission, we also need to track their potential commission. Each employee is assigned a unique number. Our company is divided into departments. Each employee is assigned to a department - for example, accounting, sales, or development. We need to know the department responsible for each employee and the department's location. Each department has a unique number - for example, accounting is 10 and sales is 30. Some of the employees are managers. We need to know each employee's manager, and the employees each manager manages." Example : Read the following, and take 15 minutes to think about the business requirements:
ITN MySQL Database Programming 12 Business Information Requirements’ Result " I manage the Human Resources Department for a large company. We need to keep information about each of our company's employees. We need to track each employee's at first name, last name, job, hire date, and salary. For any employees on commission, we also need to track their potential commission. Each employee is assigned a unique number. Our company is divided into departments. Each employee is assigned to a department - for example, accounting, sales, or development. We need to know the department responsible for each employee and the department's location. Each department has a unique number - for example, accounting is 10 and sales is 30. Some of the employees are managers. We need to know each employee's manager, and the employees each manager manages."
ITN MySQL Database Programming 13 Conceptual Data Modeling Overview Draw a diagram showing the possible columns you can get from the reading: EMPLOYEE DEPARTMENT
ITN MySQL Database Programming 14 Conceptual Data Modeling Overview In Conceptual Data Modeling, define and model the things of significance about which the business needs to know or hold information, and the relationships between them. An Entity-Relationship Data Model should accurately model the organization's information needs and support the functions of the business
ITN MySQL Database Programming 15 Conceptual Data Modeling Overview Example (continued): The following entity-relationship model represents the results of information requirements of the Human Resources Department. EMPLOYEE # * number * first name * last name o job * hire date o salary o mgr o commission o deptno DEPARTMENT # * number * name * location assigned to responsible for the manager of
ITN MySQL Database Programming 16 Database Design Overview ERD and Relational Database Design: In Database Design, map the information requirements reflected in an Entity-Relationship Model into a relational database design (Map the columns in the ERD into the table instance charts). Significance of using table instance charts: The Table Instance Chart for each relational table identifies the table's columns, primary key, unique key, and any provides a visual view of sample data.
ITN MySQL Database Programming 17 Col NameEMPNOFNAMELNAMEJOBHIREDATESALCOMMMGRDEPTNO Key Type Null/Unique Sample Data Col NameDEPTNODNAMELOC Table Name: DEPARTMENT Table Name: EMPLOYEE Key Type Null/Unique Sample Data
ITN MySQL Database Programming 18 Col NameEMPNOFNAMELNAMEJOBHIREDATESALCOMMMGRDEPTNO Key TypePK FK1FK2 Null/UniqueNN, UNN Sample Data7369MARYSMITHCLERK17-DEC HENRYFORDANALYST03-DEC SUEWARDSALESMAN22-FEB BOBBLAKEMANAGER01-MAY BOBKINGPRESIDENT17-NOV Col NameDEPTNODNAMELOC Key TypePK Nulls/UniqueNN, UNN 10ACCOUTINGNew York 20REASEARCHDALLAS 30SALESCHICAGO 40OPERATIONSBOSTON 50DEVELOPMENTATLANTA Table Name: DEPARTMENT Table Name: EMPLOYEE
ITN MySQL Database Programming 19 Database Build Overview In Database Build, create physical relational database tables to implement the database design. Example: The Structured Query Language (SQL) is used to create and manipulate relational databases. We will create the DEPARTEMNT and EMPLOYEE tables by using SQL statements. Log into the MySQL by using your user_id, and password at your Linux account.
ITN MySQL Database Programming 20 PS: The Structured Query Language (SQL) is used to create and manipulate relational databases. -- Create Table Department -- DROP TABLE department; CREATE TABLE department (deptno SMALLINT(2) NOT NULL PRIMARY KEY, dname CHAR(20) NOT NULL, loc CHAR(15) NOT NULL);
ITN MySQL Database Programming Create employee table DROP TABLE employee; CREATE TABLE employee (empnoSMALLINT(5) NOT NULL PRIMARY KEY, enameCHAR(15) NOT NULL, lnameCHAR(15) NOT NULL, jobCHAR(15), hiredateDATETIME NOT NULL, salNUMBER(7,2), commNUMBER(7,2), mgrSMALLINT(4), deptno SMALLINT(2) NOT NULL);