CIS/336 iLab 3 of 7 - SQL CourseBeginning with this lab, and continuing through the remaining weeks you will be doing all of yourwork in Oracle itself. The editor interface to the Oracle server is SQL*Plus, and by now you havereceived your logon ID and password and should have at least made sure you can connect. If forany reason you have not done so, please do so now before continuing any further. If for any reasonyou cannot connect then you need to let the instructor know ASAP so that any problems can beresolved.Before attempting Lab #3, you need to be sure you have read through the SQL*Plus tutorial whichcan be found in Doc Sharing as well as under the SQL*Plus Tutorial tab in Week 3. This tutorialdescribes the functionality of the editor and will take you through the process of setting up andusing the SQL*Plus in the iLab environment so that it will best serve your needs for the remainder ofthe labs required for this course.The lab for this week addresses taking a logical database design (data model) and now transformingthat into a physical model (tables, constraints, and relationships). As part of the lab, you will need todownload the Zip file titled "Lab 3 Support Documents" from Doc Sharing. This Zip file containsthree documents: Lab 3 Relationship Diagram.docx, Lab 3 Meta Data Diagram.xlsx, and Lab 3 InputData.docx.Your job will be to take the meta data defined in the data dictionary spreadsheet document, andusing the relationship diagram as a guide define the table structures and constraints using bothCREATE TABLE and ALTER TABLE statements. Once this has been done, you will need to write theINSERT INTO TABLE statements to insert the data provided into the table. The data should verifythat the constraints you have created are valid and define the correct referential and data integrityconstraints asked for. Lastly, you will write SELECT statements to query the tables and verify thedata was populated.Narrative/Case StudyFor this lab, you be working with command-line SQL to build a series of relational tables, using SQLCREATE statements in a script file format for the Student Database and then populate those tablesthrough the use of INSERT statements with sample data.You will need to create a script file and name it YourName_Lab3.txt containing the followingcode:The drop table statements listed later in the specifications of this lab.The CREATE TABLE statements required to build the seven (7) tables.
The INSERT statements necessary to insert all of the sample data.Seven select statements to verify that the data is in the tables and accessible.To help you accomplish this task successfully, you are being supplied with the following threedocuments which can be found in the Doc Sharing tab on the course website:A Relationship Diagram of the database showing in graphical form the 1:M relationships betweenthe tables (336_Lab3_Relationship_Diagram.doc).A Meta Data chart providing information about table names, column names, etc. Be sure to followthis reference exactly when constructing your CREATE TABLE statements (336_Lab3_Data_Dict.xls).A listing of sample data to use when writing the INSERT statements to populate the tables(336_lab3_input_data.doc).The following guidelines are being provided to help assist you in creating your script file:Create the tables in the order shown in the data dictionary. Use the names for the tables andcolumns as listed in the Meta Data chart – Do not change them as it will affect your grade.Creating CONTRAINTS -Create all constraints as indicated in the data dictionary.Constraint suffixes must be as follows:Primary key constraint – PKForeign key constraint – FKCheck constraint - CCExplicitly name all constraints PRIMARY KEY, FOREIGN KEY, and CHECK constraints to reflect:TableName_ColumnName_ConstraintSuffix (For example, to name a PRIMARY KEY constraint on theSID column in the student table you would use STUDENT_SID_PK.)For this lab you do not have to explicitly name NOT NULL constraintsCreate all PRIMARY KEY and NOT NULL constraints within the CREATE TABLE statements at thecolumn level (line level), unless the Primary Key is a composite Primary Key (yes, there is one).Composite Primary Key constraints must be created at the table level. Create all FOREIGN KEY andCHECK constraints at the table level using ALTER TABLE statements. All constraints must be addedprior to populating the tables with data. Create all of the tables and all of the constraints beforepopulating any of the tables with data. Insert statements must be in the same order as the tablesare created (follow the order in the sample data file). ALL character strings must be enclosed in
single quotes. This includes alpha strings and alphanumeric (remember that any formatting within anumeric strings makes it alphanumeric). If you are inserting a NULL, do not enclose the word NULLin single quotes, as this will insert the word NULL into the row. To insert a null you simply use theword NULL.DeliverablesThe deliverable for this lab will include the following documents.Your script file. Create this file in Notepad not Word. Make sure your name is in a comment area atthe top of the script file. Use a double dash to create a one line comment:--Jacob Smith--Lab 3Your lab output file created using a spool session in SQL*Plus.Be sure to use the SET ECHO ON session command when creating the output file so that both theSQL commands and results will show in the output. Be sure your name is on all documents and thatall documents have been included in a single Zip file for this week’s assignments.LABSTEPSSTEP 1: The DROP statementsThe following DROP TABLE statements must appear at the top of your script file. This will allow youto run and re-run your script file as often as you need to. The first time you run your script file youwill get an ERROR on the drop statements saying the Table or View does not exist. This is true sinceit has not been created yet, but the error is more informational than anything. Once the tables arecreated, you will not get this error again.DROP TABLE ENROLLMENT CASCADE CONSTRAINTS PURGE;DROP TABLE COURSE_SECTION CASCADE CONSTRAINTS PURGE;DROP TABLE COURSE CASCADE CONSTRAINTS PURGE;DROP TABLE TERM CASCADE CONSTRAINTS PURGE;DROP TABLE STUDENT CASCADE CONSTRAINTS PURGE;
DROP TABLE FACULTY CASCADE CONSTRAINTS PURGE;DROP TABLE LOCATION CASCADE CONSTRAINTS PURGE;STEP 2: The CREATE TABLE statementsNext, define the CREATE TABLE statements for the seven tables that you are to create based uponthe ERD and Data Dictionary that you have been given for this lab. Be sure to follow the guidelinesgiven above on how and where to create the different types of constraints for each table.STEP 3: The INSERT statements for the dataThe third step is to create the insert statements to insert the sample data into the tables created inStep 2. You might find it helpful to take the Word document containing the sample data and save itas a text file. After doing this, you could create the insert statements around the actual data that isin that file. The process for doing this should have been covered in one of the lectures for this unit.If it was not, then ask your instructor to discuss this process with the class.STEP 4: The SELECT statementsThe next step of the lab will be to create the select statements to verify the data was insertedcorrectly. You should have seven select statements; one for each table. The command is SELECT *FROM Table_Name; For example, to select all columns from the Student table, the command wouldbe SELECT * FROM Student;Be sure to save all of the above statements in your script file.STEP 5: Testing and verifying your scriptNow we come to the point of verifying that your script file works by creating all of the tables andinserting all of the data. To verify this you will need to execute your saved script file and create anoutput file to capture the results being returned to the session by using the spool COMMANDoutlined in the tutorial "Using Oracle SQL*Plus." This output file will be one of the files you will beturning in for grading.CLICK HERE TO GET THE SOLUTION !!!!!!!