понедельник, 9 ноября 2015 г.

MIS 582 iLab 3 of 4 The Week 5 iLab Database Construction Using MySQL


iLAB OVERVIEW
Scenario/Summary
In this assignment, you will learn to create a Database Schema from a given ERD. To complete this assignment, you will need to be able to run MySQL via Omnymbus.
Please ensure that you can connect to MySQL/Omnymbus. Consult with the document titled MySQLOmnymbusSupport.docx located in the Doc Sharing folder titled Omnymbus Tutorial Files for instructions. Contact your instructor for help for any issues that you are having with the MySQL/edupe Environment.
Deliverables
SQL script file named LastName_Wk5.sql. That is a txt document with the .sql extension. A text document namedLastName_Wk5_Output.txt. When you are done submit them to the Week 5: iLab Dropbox. Files that have been opened or processed by any software than Notepad are not acceptable. Zipped files are not acceptable and may be returned ungraded.
Required Software
Omnymbus – MySQL in the edupe environment. SQLZOO may be used to test the scripts.
Access the software at https://devry.edupe.net:8300.
Steps 1–8
iLAB STEPS
STEP 1: Entity Relationship Diagram Analysis
Review the ERD below to understand the entities, attributes, primary keys, and relationships that you will create in your MySQL database.
STEP 1: Create a New Database
Create a new database following the naming conventions we are using for our databases, as specified in the tutorial file Creating a Database within MySQL.pdf listed in the doc-sharing folder titled “Omnymbus Tutorial Files” in Doc-Sharing. All of our work in this iLab, will be done under this database.
STEP 2: Create SQL File
  • To reference, learn and apply MySQL’s own dialect of the SQL language to this iLab, browse through the file M10C_KROE8352_13_SE_WC10C.pdf in the Doc Sharing folder titled My SQL Documents.
  • Create a script file named LastName_Wk5.sql containing SQL statements created in Steps 3–7 below.
  • But first include the following commands at the top of your script:
    • SET FOREIGN_KEY_CHECKS=0;
    • DROP TABLE IF EXISTS STUDENT;
    • DROP TABLE IF EXISTS CAMPUS;
    • DROP TABLE IF EXISTS ROOM;
    • DROP TABLE IF EXISTS COURSE;
    • DROP TABLE IF EXISTS INSTRUCTOR;
    • DROP TABLE IF EXISTS APPROVED_INSTRUCTOR;
    • DROP TABLE IF EXISTS CLASS;
    • DROP TABLE IF EXISTS STUDENT_GRADE;
    • SET FOREIGN_KEY_CHECKS=1;
STEP 3: Add Tables, Set Primary Keys and Foreign Keys
Add tables to the MySQL database.
  • Add a table for each entity listed in the provided ERD diagram.
  • Add a column for each attribute listed in the provided ERD diagram.
  • Select primary key for each table as indicated in the provided ERD diagram.
  • Identify foreign key relationship between tables as indicated in the provided ERD diagram.
  • Enable referential integrity on the relationship.
  • Enable cascade updates on the relationship.
STEP 4: Set Data Types for Table Fields
For every column in every table, update the data type as needed to enforce the domain constraints of the data.
  • Dates should have a date data type.
  • Surrogate keys should be auto-numbered.
  • Numeric data should have a numeric data type.
  • Character data should have a character data type.
STEP 5: Set Column Constraints
Set the following column constraints in your database.
  • Student first and last name cannot be a null value.
  • Course credit hours must be between one and four.
  • Course name must be unique and cannot be a null value.
  • Instructor first and last name cannot be a null value.
  • Grade must be one of these values: A, B, C, D, F, I, W, or E. W signifies withdrawn and E signifies enrolled.
STEP 6: Add Data to Tables
Write INSERT statements to add at least 2–3 rows of data to each table in your database. Use any values that you like for each of the columns. Remember that you must add data to parent tables before adding data to child tables, because referential integrity is enabled.
STEP 7: Run the Script
  • Include a COMMIT command at the end of the script.
  • Include SHOW TABLES command at the end of the script, to show all tables created.
  • Include SELECT statements for each table at the end of the script, to show data inserted.
  • Give your script a run, by uploading into Omnymbus and executing it just like you did in iLab1.
  • Paste a copy of the output in a MS Word document namedLastName_Lab3_Output.
Step 8: Save and Upload to Dropbox
When you are done, submit the following files to the Week 5: iLab Dropbox:
  • LastName_Wk5.sql A text file you created with Notepad
  • LastName_Wk5_Output.txt A text file created by copy and paste from edupe.
Rubric
Points will be awarded according to the following rubrics.
  • 5 points: Table created for each entity in the provided E-R model
  • 5 points: Column created for each attribute in the provided E-R model
  • 5 points: Primary key added for each table with unique constraints specified as column properties
  • 5 points: Data type set for each attribute
    • Dates should have a date data type.
    • Surrogate keys should be autonumbered.
    • Numeric data should have a numeric data type.
    • Character data should have a character data type.
  • 10 Points: Relationships created as shown on the provided E-R model
    • Relationships enabled for referential integrity
    • Relationships enabled for cascade updates.
  • 10 Points: At least five rows of data added for each table
  • 10 Points: Column constraints added as indicated in project description, checked by adding rows to data with invalid values
    • Student name cannot be set to null.
    • Course credit hours are restricted to between one and four.
    • Course name must be unique and cannot be set to null.
    • Instructor last name and first name cannot be set to null.
Grade is restricted to be one of these values: A, B, C, D, F, I, W, or E (enrolled).

MIS 582 Week 2 Task 1 SQL Queries Using MySQL



/*Using the STUDENT table in the MISLab1 database in Omnymbus, perform the following tasks: Note the first SELECT is there to label the output, DUAL is a "dummy" table. The second SELECT is the solution.
1. Write a SQL statement to display Student’s First and Last Name.*/
SELECT ' Result 1 ' AS 'Result Table' from DUAL;
SELECT STUDENT.First_Name , STUDENT.Last_Name
FROM STUDENT;
/*2. Write a SQL statement to display the Major of the STUDENT with no duplications. Do not display student names.*/
SELECT ' Result 2 ' AS 'Result Table' from DUAL;
SELECT Distinct STUDENT.Major
FROM STUDENT;
/*3. Write a SQL statement to display the First and Last Name of students who live in the Zip code 82622. */
SELECT ' Result 3 ' AS 'Result Table' from DUAL;
SELECT STUDENT.First_Name , STUDENT.Last_Name
FROM STUDENT
WHERE STUDENT.ZIP ="82622";
/*4. Write a SQL statement to display the First and Last Name of students who live in the Zip code 97912 and have the major of CS.*/
SELECT ' Result 4 ' AS 'Result Table' from DUAL;
SELECT STUDENT.First_Name , STUDENT.Last_Name
FROM STUDENT
WHERE STUDENT.ZIP ="82622" AND STUDENT.MAJOR="CS";
/*5. Write a SQL statement to display the First and Last Name of students who live in the Zip code 82622 or 37311. Do not use IN.*/
SELECT ' Result 5 ' AS 'Result Table' from DUAL;
SELECT STUDENT.First_Name , STUDENT.Last_Name
FROM STUDENT
WHERE STUDENT.ZIP ="82622" OR STUDENT.ZIP ="37311";
/*6. Write a SQL statement to display the First and Last Name of students who have the major of Business or Math. Use IN.*/
SELECT ' Result 6 ' AS 'Result Table' from DUAL;
SELECT STUDENT.First_Name , STUDENT.Last_Name
FROM STUDENT
WHERE STUDENT.MAJOR IN ("Business","Math");
/*7. Write a SQL statement to display the First and Last Name of students who have the Class greater than 1 and less than 10. Use the SQL command BETWEEN. */
SELECT ' Result 7 ' AS 'Result Table' from DUAL;
SELECT STUDENT.First_Name , STUDENT.Last_Name
FROM STUDENT
WHERE STUDENT.CLASS BETWEEN 1 AND 10;
/*8. Write a SQL statement to display the First and Last Name of students who have a Last name that starts with an S.*/
SELECT ' Result 8 ' AS 'Result Table' from DUAL;
SELECT STUDENT.First_Name , STUDENT.Last_Name
FROM STUDENT
WHERE STUDENT.Last_Name LIKE "S%";
/*9. Write a SQL statement to display the First and Last Name of students having an a in the second position of their first names.*/
SELECT ' Result 9 ' AS 'Result Table' from DUAL;
SELECT STUDENT.First_Name , STUDENT.Last_Name
FROM STUDENT
WHERE STUDENT.First_Name LIKE '_a';
/*10. Write a SQL expression to display each Status and the number of occurrences of each status using the Count(*) function; display the result of the Count(*) function as CountStatus. Group by Status and display the results in escending order of CountStatus.*/
SELECT ' Result 10 ' AS 'Result Table' from DUAL;
SELECT STUDENT.STATUS, Count(*) AS CountStatus
FROM STUDENT
GROUP BY STUDENT.STATUS
ORDER BY CountStatus ASC;

MIS 582 Week 6 Task 3 Database Construction Using MySQL


MIS582 COURSE PROJECT
Week 6: Task 3: Database Construction Using MySQL (50 Points)
NOTE: MySQL is required for this project. Please ensure you can run MySQL via Omnymbus.
PROJECT OVERVIEW:
Scenario and Summary
In this assignment, you will create and populate a MySQL database based on the ERD you created in task2. Update the ERD you submitted for task2 with the corrections required by your instructor. To help you with this task, the data dictionary of the database is available in Doc Sharing. This will provide you information on every table that you must create for the ABC Company database. Every entity can be found listed in the data dictionary along with the PK/FK information as well as the data types for the attributes. These data types are MySQL data types so they can go directly in the create table statements. Using the corrected ERD and the data dictionary provided, write the necessary MySQL statements to create the ABC company database.
Deliverables
1. Script file as Lastname_task3.sql which includes all of the drop, create, alter, and insert statements needed to create the ABC Company database.
2. Text showing the copied and pasted run result of the script file saved as Lastname_task3Result.txt.
3. When you are done, upload the two files to the Week 6: Course Project Week 6 Task 3 Dropbox.
STEP 1
Revise the ERD you submitted for the previous task with the feedback provided by your instructor and the help of the given data dictionary document.
STEP 2
  • Create a file with the name Lastname_Task3.sql
  • In your sql file, to drop the tables in case you run the script repeatedly, please include the following at the top of your script (Please note that the capitalization must conform to YOUR table creates!):
  • o SET FOREIGN_KEY_CHECKS=0;
    o DROP TABLE IF EXISTS Inventory CASCADE;
    o DROP TABLE IF EXISTS inventory CASCADE;
    o DROP TABLE IF EXISTS line_item CASCADE ;
    o DROP TABLE IF EXISTS product CASCADE;
    o DROP TABLE IF EXISTS orders CASCADE;
    o DROP TABLE IF EXISTS store CASCADE;
    o DROP TABLE IF EXISTS employee CASCADE;
    o DROP TABLE IF EXISTS department CASCADE;
    o DROP TABLE IF EXISTS Warehouse CASCADE;
    o DROP TABLE IF EXISTS region CASCADE;
    o SET FOREIGN_KEY_CHECKS=1;
  • In your sql file, write create table statements for each table in the database. You can try to create each table one at a time and then test the creation of the table before going on to creating the next table. Use the data types given in the data dictionary. Make sure every table has primary key(s), foreign keys if required, and not nulls if required. (Refer to data dictionary for this information)
  • Save the completed script file.
  • Create a database following the proper naming convention as specified in the tutorial Creating a Database in MySQL Omnymbus Environment.docx noted at the end of this document.
  • Click on the database name you just created.
  • Run the script file as specified in the tutorial Running SQL Scripts in MySQL Omnymbus Environment.docx noted at the end of this document. The technique is demonstrated in the Live Lecture. If there are no errors, all tables will be successfully created. You may check them by adding SHOW TABLES at the end of your script file.
  • If you have errors, correct those errors and execute the script again until it is error free.
  • STEP 3
    Adding data to your database.
  • In your SQL Script, write insert statements to successfully insert data into each table.
  • A minimum of 3 rows are required for each table.
  • In your SQL Script, check the data in each table by running a SELECT * FROM table query.
  • Run your SQL Script to test it.
  • When you are satisfied with you’re the output of your SQL Script, copy the output to a Word File.
  • Rubrics
    Points for will be awarded according to the following rubrics.
  • 10 Points: Visio drawing: Revised E-R model provided as a Visio diagram.
  • 15 Points: CREATE STATEMENTS: Successfully creating all tables.
  • 5 Points: PRIMARY KEYS: Correct primary keys created for all tables.
  • 5 Points: FOREIGN KEYS: All required foreign keys created.
  • 5 Points: ALTER STATEMENT: Any alter statements required.
  • 10 Points: INSERT STATEMENTS: Minimum three rows per table found.
  • Tutorials to Consult With
    M10C_KROE8352_13_SE_WC10C.pdf in the folder titled My SQL Documents in Doc Sharing for all things to do with MySQL including example SQL.
    Login MySQL Omnymbus Environment.docx in the folder titled Omnymbus Tutorial Files in Doc Sharing for how to log into the Omnymbus Environment.
    Creating a Database in MySQL Omnymbus Environment.docx in the folder titled Omnymbus Tutorial Files in Doc Sharing for how to create a Database the Omnymbus Environment. Remember, all work must be done under a database your first create.
    Running SQL Scripts in MySQL Omnymbus Environment.docx in the folder titled Omnymbus Tutorial Files in Doc Sharing for how to create and run your SQL Scripts.
    DBP-e13-Appendix-F.pdf in the folder titled Visio Instructions Documents in Doc Sharing for how to use Visio 2013.
    kroenke_dbp12e_appendix_f.pdf in the folder titled Visio Instructions Documents in Doc Sharing for how to use Visio 2010.
    COURSE PROJECT Week6Task3DataDictonary.xlsx in the folder titled Course Project Documents in Doc Sharing.

    MIS 582 Week 7 COURSE PROJECT


    MIS582 COURSE PROJECT

    The Course Project will consist of three tasks, each worth 50 points due in Weeks 2, 4, and 6. Successful completion of the iLabs will help you in completing the project tasks.
    Week 4: Task 2: Data Modeling Using Visio (50 Points)
    NOTE: Visio 2010 is required for this project. Please ensure you can run Visio 2010 via Citrix or by having it installed on your computer. In case you are to run Visio 2013, there is a tutorial listed at the bottom of this document for that version of Visio, as well as a tutorial for Visio 2010.
    PROJECT OVERVIEW:
    Scenario and Summary
    In this assignment, you will learn to create a physical database model in Visio from business requirements. To complete this assignment, you will need to be able to run Visio 2010, either through Citrix or installed on your workstation or laptop.
    Deliverables
    Name your Visio file as Lastname_Task2.vsd. Create and save your database model in your Visio file. When you are done, submit your document to the Week 4: Course Project Task 2 Dropbox.
    STEP 1
    Read the following business requirements closely to determine the entities and relationships needed to fulfill the requirements. The nouns in the paragraph will tell you the entities that will be needed. The adjectives that describe those nouns are the attributes of that entity. The verbs in the paragraph will help you determine the relationships between the entities.
    ABC Company Order Inventory System
    Database Requirements
    The ABC company has many stores in many locations that are divided in regions. The company supplies products to these stores. For the purposes of this database you may think that it is an American company in terms of regions such as Midwest.
    Each store is their customer/client. The company recognizes these stores by their store ID. They also keep track of the store name, address, and contact name.
    Stores may place orders online, or by phone/fax. Each order must be uniquely identified by an order number. Each order has a date on which the order was made, a date when the order was shipped, an employee who took the order (or it could be an online order), and the mode of payment.
    To make sure that the stores get their order on time, the stores are assigned to different warehouses in different regions. Currently, there is one warehouse for every region. Each warehouse is identified by its warehouse number. The company also tracks the address of the warehouse as well as a contact phone number.
    There are five regions: West, Midwest, Southwest, Southeast, and Northwest. Each region is identified by its unique name and unique number.
    Each warehouse holds many products for this company. A product may be found in many warehouses. The company keeps track of this inventory. At any point in time, the company must be able to find which warehouses carry this item, the quantity in stock, reorder point and whether this item is out of stock.
    Each product has a unique id, a description, a price. Each product could be on many orders, and an order may have multiple products on it. The company needs to track what quantity was ordered for each product and the total price for those products.
    Phone/Fax orders are processed by the employees of the company. The company keeps track of the employee’s id, first and last names, position, hire date, department they work for, their supervisor, and their salary.
    STEP 2
    • Run Visio 2010 either via Citrix or on your workstation.
    • Click on the Software and Database template group in the main window.
    • Double-click on the Database Model Diagram template to open a new file.
    • Save the file with the name Lastname_Task2.vsd. You will need to click the computer icon in the Save As window to see the different drives. Be sure to save the file to a local drive so it will be on your workstation.
    STEP 3
    Add an entity for each entity you identified in the requirements.
    • Drag the entity icon onto the drawing area in Visio.
    • In the Database Properties window, add a physical name to identify it.
    STEP 4
    For each entity, create a list of attributes you think would be useful to describe the entity.
    • Select an entity in the drawing area of Visio.
    • In the Database Properties window, select the Columns category.
    • Use the table to add your attributes to the selected entities.
    • Select the primary key (PK).
    STEP 5
    Set the diagram to use crow's feet notation.
    • On the Database tab, in the Manage group, click Display Options.
    • In the Database Document Option dialog, select the Relationship tab.
    • Select the Crow's Feet check box, and then click OK.
    STEP 6
    Draw relationships between your entities.
    • Drag the relationship icon onto a blank part of the drawing area.
    • Connect the two ends to each of the two entities in the relationship. The parent entity must have a PK defined. The entity will be outlined in bold red lines when it connects to one end of the relationship.
    STEP 7
    Set the cardinality of your relationships.
    • Select a relationship line in the drawing area that is connecting two entities.
    • In the Database Properties window, select the Miscellaneous category.
    • Select the cardinality for the selected relationship.
    STEP 8
    When you are done, save the file on your local hard drive and upload it to the Week 4: Course Project Week 4 Task 2Dropbox. Your file should have the following filename format:Lastname_Task2.vsd.
    For instructions on how to copy files between the Citrix server and your local machine, watch the iLab tutorial, Copying Files From Citrix, located in the iLab menu tab under Course Home.
    Rubrics
    Points for will be awarded according to the following rubrics.
    • 10 Points: Visio drawing: E-R model is provided as a Visio diagram.
    • 10 Points: Entities: A minimum of six entities are present.
    • 10 Points: Attributes: There are more than two attributes per entity; in most cases there should be several.
    • 10 Points: Relationships: A minimum of six correct relationships are present.
    • 10 Points: Correct cardinality is specified on each relationship with crow's foot notation.
    Tutorials to Consult With
    DBP-e13-Appendix-F.pdf in the folder titled Visio Instructions Documents in Doc Sharing for how to use Visio 2013.
    kroenke_dbp12e_appendix_f.pdf in the folder titled Visio Instructions Documents in Doc Sharing for how to use Visio 2010.