SlideShare a Scribd company logo
1 of 65
Download to read offline
CIS 336 Final Exam (July,2019)
FOR MORE CLASSES VISIT
www.cis336study.com
Question 1. 1. (TCO 1) A DBMS performs several important functions
that guarantee the integrity and consistency of the data in the database.
Which of the following is NOT one of those functions?
Question 2. 2. (TCO 1) A relational DBMS provides protection of the
_____ through security, control, and recovery facilities.
Question 3. 3. (TCO 2) A relationship is an association between _____
==============================================
CIS 336 Final Exam 1 (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
1. (TCO 1) Most DBMS are referred to as _____________database
management systems. (Points : 4)
elemental
linked
hierarchical
relational
2. (TCO 1) Data constitutes the building blocks of _____________.
(Points : 4)
information
processing
applications
programming
==============================================
CIS 336 Final Exam 2 (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
1. (TCO 1) Most DBMS are referred to as _____________database
management systems. (Points : 4)
elemental
linked
hierarchical
relational
2. (TCO 1) A relational DBMS provides protection of the
_______________________ through security, control, and recovery
facilities. (Points : 4)
user
network
system
database
==============================================
CIS 336 Final Exam 3 (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
1. (TCO 2) Explain what physical independence means. (Points : 15)
2. (TCO 8) Sally wants to query the EMP table and determine how many
of the employees live in each of the cities the company has factories in.
She writes the following query but it does not work. What is wrong with
the way the query is constructed?
3. (TCO 3) Explain in what two specific cases presented in the text
composite primary keys are particularly useful. (Points : 15)
4. (TCO 7) How are comparisons done on character string data in a
queries WHERE clause, and why would this be especially useful in
comparing certain attributes? (Points : 15)
==============================================
CIS 336 Final Exam 4 (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
1. (TCO 7) For every order, list the order number, order date,
part number, part description, and item class for each part that
makes up the order.
2. (TCO 8) Write a query that will display the customer number,
last name, and first name for every customer I whose first name
begins with the letter "D".
2. (TCO 8) Write a query that will display the earliest date an
order was placed.
==============================================
CIS 336 Final Exam 4 Sets of Answers (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
CIS 336 Final Exam 4 Sets of Answers
==============================================
CIS 336 Group Project
FOR MORE CLASSES VISIT
www.cis336study.com
This project is designed to touch all aspects of the fundamental concepts
of database design and logical data modeling covered during the class.
Each student will be responsible for designing, developing, and
demonstrating the functionality of a database created based on a set of
business specifications that you create. At the end of the session, each
student will submit a report that includes the logical and physical design
of the database and demonstrates the database's ability to deliver
meaningful reports. All aspects of the project will be covered during the
week or weeks prior to a deliverable, and each task deliverable in the
project will be supported through the exercises and labs done in the
course.
Guidelines
You will create a proposal for a commerce business of your choosing.
This can be an actual or fictional business that sells products and/or
services. You will determine the business rules and report requirements.
Entities that must be included in your model are the following.
Customer
Product (or Service)
Order
Project Deliverables
This task is broken down into four deliverables.
· Task 0
· Task 1
· Task 2
· Task 3
Remember that this is a work in progress and in all likelihood, you will
have to make numerous changes to your tables and schema as you go
along. These changes are to be expected and are a normal part of the
database design and implementation process.
Please refer to the sections below for details regarding deliverables for
each task.
Task 0
The first task is to create your business narrative. Some of the questions
that you should address include (but are not limited to) the following.
· What is the name of your business?
· Who will be the users of the system (managers, employees,
customers)?
· What product(s) and or service(s) does it sell? Be specific.
· Who are the customers? What is the customer base?
· What sales and distribution channels are used?
· How are payments made?
· Are products delivered or shipped to customers in some way?
· Are sales reps involved? Are they paid on commission?
· What type of reports are needed by the business?
Please include as much detail as possible in order to provide a
foundation for Task 1. Submit your proposal as a Word document. Note
that this proposal may be revised in the coming weeks as your
understanding of the database modeling process grows.
Task 1
Develop a detailed logical model of your database based on your
business scenario submitted for Task 0. Your data model will include an
entity-relationship diagram (ERD) developed with Microsoft Visio or
MySQL and a data dictionary (DD) developed with Microsoft Excel.
Note that your deliverables each week include any revisions to the
previous task.
Submit your Task 1 deliverable as a zip file including the following.
· Task 0 proposal (with any revisions or updates)
· Your ERD copied to a Word document that fits on a single 8 x 10
page
· Your DD (Excel file)
Task 2
First, make sure to make any necessary revisions to your logical model
based on Task 1 feedback. Using MySQL, write the statements to
develop a physical model of your database by creating the tables and
constraints based on your Task 1 logical model. Be sure to use your
ERD and data dictionary and create all constraints appropriately.
Once your tables are created, you will populate them with data using
MySQL statements to insert records into the database. You should insert
a minimum of five records into each table and more where necessary to
ensure that the data in the database is sufficient to allow for each of your
reports to be tested.
The result will be a script file that includes statements to
· DROP all tables;
· CREATE all tables with constraints;
· INSERT data into all tables; and
· SELECT data from all tables to show the data in each table.
Name this file yourname_task2.txt.
Also create a Word document that shows the structure of each table and
the data in each of your tables (copy and paste from MySQL). Name this
file yourname_tables.docx.
Note that your deliverables each week include any revisions to a
previous task.
Submit your Task 2 deliverable as a zip file including the following.
· Task 0 proposal (with any revisions)
· Your Task 1 ERD (with any revisions)
· Your Task 1 DD (with any revisions)
· Your Task 2 script file to create and populate tables
(yourname_task2.txt)
· A Word document showing all tables and data
(yourname_tables.docx)
Task 3
Your final task is to use your tables for an update and for reports. There
are two requirements.
1. You will demonstrate an update that includes two tables and uses a
subquery. Make sure to prove that your update executed correctly by
showing data in the tables before and after the update.
2. You will also develop at least four meaningful reports. One must
include a join, one must use a subquery, and one must use an aggregate
function. You need to describe the business requirement of the update
and each report. Note that numeric PK values are not often meaningful
to a person looking at the report. You will create a script file that has
each of the queries called yourname_task3.txt. You will also document
the results of this task in a Word document called
yourname_reports.docx to show the result of each query. For the update
and each report,
· describe the update and report requirement;
· show the query; and
· show the result of the query.
Include a final section for Conclusions and Lessons Learned regarding
the project.Note that your deliverables each week include any revisions
to a previous task.Submit your Task 3 deliverable as a zip file including
the following.
· Task 0 proposal (with any revisions)
· Your Task 1 ERD (with any revisions)
· Your Task 1 DD (with any revisions)
· Your Task 2 script file to create and populate tables (with any
revisions)
· A Word document showing all tables and data (with any
revisions)
· Your Task 3 script file with update and reports
(yourname_task3.txt)
· A Word file with results of Task 3 and lessons learned
(yourname_reports.docx)
==============================================
CIS 336 iLab 1 Normal Forms and Entity Relationship
Diagrams
FOR MORE CLASSES VISIT
www.cis336study.com
CIS336 Lab 1: Normal Forms and Entity Relationship Diagrams
Introduction
In this exercise, you will analyze a de-normalized data set presented in
the form of a spreadsheet. You will next construct a series of
dependency diagrams, transforming the evolving data model from First
Normal Form (1NF), to Second Normal Form (2NF), and finally to
Third Normal Form (3NF). When the model has reached 3NF, you will
construct the Entity Relationship Diagram (ERD) depicting the logical
design of the database. Your ERD will use Crow‘s Foot notation to
denote the relationships between tables.
Sample Exercise, With Solution
Before completing your lab, please review this example problem. The
diagram below is a partial depiction of a business spreadsheet for a retail
store operation. The store sells books. Books have a 13-digit
International Standard Book Number (ISBN), a title, a publisher, and a
unit price. Invoices track sales of books. An Invoice contains one or
many line items, with each line item reflecting the sale of one or more
copies of a specific book. Every publisher has a company name, and a
publisher code.
InvNum ISBN13 InvDateBookTitlePubCodePubNameQtyunitPrice
1022 9781291940336 2015-03-09 MYSQL Functions 1001 Lulu.com 3
4.99
1022 9780321833877 2015-03-09 MySQL, Fifth Edition 1029 Addison-
Wesley 5 33.95
1022 9781890774820 2015-03-09 Murach‘s MySQL, 2nd Edition 1032
Murach, Mike & Associates, Inc 2 48.95
1249 9781449374020 2015-02-22 MySQL Cookbook: Solutions for
Database Developers and Administrators 1118 O‘Reilly Media,
Incorporated 9 50.59
1249 9781449325572 2015-02-22 PHP & MySQL: The Missing Manual
1118 O‘Reilly Media, Incorporated 6 29.95
1249 9781890774790 2015-02-22 Murach‘s PHP and MySQL, 2nd
Edition 1032 Murach, Mike & Associates, Inc 1 48.95
BookSales
1. Using the BookSales table structure shown above, draw the
dependency diagram, and show all dependencies, full, partial, and
transitive.
Figure 1 -solution 1
Discussion: A composite primary key consisting of InvNum + ISBN13
can be constructed, ensuring that all rows are unique. All remaining
attributes are shown to be dependent (at least partially) on this composite
key, so the table is 1NF. Further analysis shows that InvDate is
dependent on only part of the key (InvNum), and that unitPrice,
PubCode, and BookTitle also depend on part of the key (ISBN13). A
transitive relationship is also revealed: PubName truly depends on
PubCode, which in turn depends on ISBN13.
2. Using the answer to exercise 1, remove all partial dependencies and
draw the new dependency diagrams. For each new table created, specify
its normal form (1NF, 2NF, 3NF).
Figure 2- solution 2
Discussion: To achieve 2NF, we must remove partial dependencies. This
is done by decomposing into three tables, and three dependency
diagrams at this stage. Notice that the Transitive relationship has not yet
been addressed.
3. Using the answer to exercise 3, remove all transitive dependencies,
and draw the new dependency diagrams. For each new or revised table,
specify its normal form.
Figure 3 – Solution 3
Discussion: The transitive relationship has been removed by creating the
Publishers table, in which PubName is fully dependent upon PubCode.
Pubcode also persists as a dependent attribute and Foreign Key in
Books. All tables are now in 3NF, and have been given meaningful
names reflecting the entities they represent. LINEITEMS represents the
collection of line items for all invoices. Invoices represents the
collection of Invoices for all customer orders. Books makes up the list of
all books available for sale (whether they have ever been ordered or not).
Each book has a publisher, and the publisher code and Name reside in
the Publishers table.
4. Draw the ERD for exercise 3, using Crow‘s Foot notation.
End of Sample Exercise.
Student Exercise
The student exercise for this lab is similar to the sample exercise
presented above.
Consider the following spreadsheet containing information about
customers, their shipping and billing addresses, and the countries
corresponding to each of those addresses. A customer may be associated
with zero to many addresses. A customer may have 0 or 1 default billing
address. A customer may have 0 or 1 default shipping address. Each
address may be associated with 0 or 1 countries, while each country may
be associated with 0 to many addresses.
cust_idfnamelnamedef_bill_addr_iddef_ship_addr_idaddr_idstreet_addr
city state zip country_codecountry_name
202 John Smith 1096 2039 1096 123 Happy Ave. Orlando FL 32801 76
United States
202 John Smith 1096 2039 2039 2024 Shorline Dr. Seattle WA 98101
76 United States
202 John Smith 1096 2039 8053 100 N. Kent Ave. St. James WA 34
Jamaica
175 Hilda Yeager 2172 2172 3879 48 Spatzel Ct. Dusseldorf 5111 29
Germany
175 Hilda Yeager 2172 2172 3921 162 Rue Moritz Paris 75001 28
France
321 Siri Apple 1881 1881 1881 1 Infinite Loop Cupertino CA 95014 76
United States
Using the example solution as a guide, perform the following steps.
1. Using the CustomerAddressCountry spreadsheet show above, draw
the dependency diagram, and show all dependencies, full, partial, and
transitive. Paste your solution into the answer sheet, and label it, Answer
#1.
2. Using the answer to exercise 1, remove all partial dependencies and
draw the new dependency diagrams. For each new table created, specify
its normal form (1NF, 2NF, 3NF). Paste your solution into the answer
sheet, and label it, Answer #2.
3. Using the answer to exercise 3, remove all transitive dependencies,
and draw the new dependency diagrams. For each new or revised table,
specify its normal form. Paste your solution into the answer sheet, and
label it, Answer #3.
4. Draw the ERD for exercise 3, using Crow‘s Foot notation. Paste your
solution into the answer sheet, and label it, Answer #4.
==============================================
CIS 336 iLab 2 The Expanded Entity Relationship Diagram
FOR MORE CLASSES VISIT
www.cis336study.com
CIS336 Lab 2: The Expanded Entity Relationship Diagram
LAB OVERVIEW
Scenario and Summary
This lab introduces the next step in creating a data model, the Entity
Relationship Diagram (ERD). You will be given a business scenario for
a University Medical Center, which is a small community hospital. The
business specifications will outline a number of things about the
business, some of which will apply directly to the database you are being
asked to model. There is a table that lists the entities (tables) that will be
needed for the database and related attributes (columns) for each entity.
There is also a column that lists specific information about the entity that
will be helpful in determining its relationship to other entities within the
model.
Be sure to include the minimum and maximum occurrences of each
relationship (cardinality) and to supply a name to the relationship that
will work in both directions. Make sure to use Crow‘s Feet notation in
your ERD.
Narrative/Case Study
The University Medical Center is a small, community hospital. A new
hospital administrator has recently been hired by the Board of Directors,
and directed to right-size patient care and pharmacy services and
improve profitability. The hospital operates three clinical facilities: the
main hospital, a mid-town clinic, and an Urgent Care location. The
hospital also offers selected in-home care services. Many of the patients
are repeat or regular patients who receive regular treatment for various
conditions, and many utilize the hospital‘s pharmacy services for
prescription medications.
The pharmacy dispenses about 3,000 different prescription medications
of various kinds. Every prescription is associated with one patient, and is
logged by the dispensing clinic. The new administrator wants to know
which drugs are most prescribed, and also which are the most profitable.
The following is some general information about the organization and its
current processes.
• The hospital operates three clinical facilities.
• A healthcare worker logs in at a facility at the start of a shift and logs
out at the end.
• The name, address, Social Security number and other information is
recorded for every healthcare worker.
• All healthcare workers have one billing rate, which is determined by
their job description.
• Each medication dispensed by prescription is linked to both the
prescription number and the medication ID number, recording the item
price and the quantity dispensed.
As a convenient and affordable means of providing hospice care,
palliative care, and convalescent care to patients that need
occasional/intermittent skilled nursing, but do not require
hospitalization, the hospital offers limited in-home care. Recording of
in-home care includes the healthcare worker ID, their departure time and
return time, and also the prescription ID for any prescriptions
administered by the healthcare worker in the home setting.
The hospital administrator would like to know what home-care visits
have been made to whom, by whom, when, and how long they took.
There is concern at this point that the cost of providing limited home
healthcare is not providing adequate return on investment, and the
program should be revised or discontinued.
Requirements
You have been asked to develop a logical data model for University
Medical Center based on the information given to you by the new
hospital administrator and their staff. Through analysis of the nouns and
verbs in the case study above, you have accumulated the following
entity, attribute, and relationship information shown in the table below.
The attribute list may not be complete. If you determine that additional
attributes are needed to better define an entity, then you should add
them.
Entities Attributes and Relationships for University Medical Center
(Parallel Lab Exercise):
Entity Attributes Relationships
HealthcareWorkerHealthcareWorkerID, LastName, FirstName, SSN,
Address, City, State, Zip, Phone Number, HealthcareWorkerTypeID A
healthcare worker can belong to any one of the three job categories, but
can belong to one and only one of the three. healthcare worker has
names and other contact information.
HealthcareWorkerTypeHealthcareWorkerTypeID,
HealthcareWorkerTypeDesc, HourlyBillingRate A healthcare worker
can be either a physician (diagnoses, prescribes medication), nurse
(provides physician-ordered treatments, administers medications), or a
pharmacist (dispenses, delivers medication).
ClinicLogClinicLogID, ClinicID, Login, Logout, HealthcareWorkerID
Patients may be treated by a healthcare worker at a clinic and can be
tracked by the clinic log number. A healthcare worker must sign into the
clinic before he or she can serve patients, and must sign out when
finished treating patients at that clinic. A healthcare worker may serve
portions of a shift at more than one clinic.
Clinic ClinicID, ClinicLocationDesc, AMAAccredNum The hospital
operates three clinical facilities: General Hospital, Midtown Clinic, and
Urgent Care.
InHomeCareInHomeCareID, HealthcareWorkerID, PrescriptionID,
DepartTime, ReturnTime. Relates to both the healthcare worker and the
prescription entities. This entity will help track provision of home
healthcare. A healthcare worker can provide many home visits but a
prescription is administered on a home visit by one and only one
healthcare worker.
Method MethodID, Method Description Relates to medication and
identifies the method of administration, for example, oral, injection, and
so on.
Medication MedicationID, MedicationName, Dosage, Cost,
QuantityOnHand, LastPurchasedDate, ReorderMinimum Identifies the
medication the hospital pharmacy dispenses. One or more medications
can be dispensed per prescription. The quantity on hand allows
Pharmacists to determine the inventory levels. The reorder minimum can
be used to determine when the inventory level has reached a reorder
point.
Prescription PrescriptionID, MedicationID, BillingAmount,
TransactionDateTime, ClinicLogID, PatientID A prescription is
identified by a single prescription order. Prescriptions are
• made to one or more patients but only one patient at a time;
• made by one or more pharmacists but only one pharmacist per
prescription;
• recorded on one or more clinics but only one clinic per prescription;
and
• administered by one or more nurses but no one prescription can be
administered by more than one nurse.
PrescribedMedicationPrescriptionID, MedicationID, ItemPrice,
QuantityDispensed Prescribed medication is part of a prescription and
records medication dispensed per prescription. Prescribed medication
must be able to associate multiple medications sold on a single
prescription number.
Patient Patient Number, First Name, Last Name, Address, City, State,
Zip, Phone Number A patient can be associated with multiple
prescriptions, but any one prescription is to one and only one patient. A
prescription can occur without a patient registering in the system (e.g.,
an unconscious patent arrives by ambulance in the emergency room and
receives life-saving emergency treatment).
Using an appropriate drawing/data modelling tool, develop an ERD that
meets the following guidelines.
• Draw the entities with their attributes.
• Indicate the relationships between the entities using Crow‘s Foot
notation. You will need to determine the cardinality and optionality for
each direction of the relationships. Some of the Foreign Key
relationships are identified in the graph above but not all. Be sure you
identify and account for all Foreign Key relationships.
• Add a name (in both directions) to the relationships. Remember, if you
can verbalize the relationship in both directions, then you probably have
a valid relationship.
Deliverables
The deliverable for this lab will be your completed ERD as a single MS
Word document using copy/paste or imported as an image from your
drawing/modelling application, cropped and sized appropriately (it
should fit on a single page), and named lab2_solutions_yourname.
LAB STEPS
STEP 1: Drawing Entities and Attributes
Back to Top
Be sure to include all of the entities that have been defined. You need to
include at least the primary and foreign key attributes where applicable
in your diagram.
STEP 2: Add Relationships
Back to Top
Be sure that you link all entities based on PK to FK relationships. There
may be a case where you need to identify a combination PK and if so
make sure that all of the relationships involved are defined. Be sure that
you have set your drawing/modelling tool set to show Crow‘s Foot
notation. Also, be sure that you are defining the correct cardinality for
the relationships.
STEP 3: Naming of relationships
Back to Top
If your drawing/modelling tool creates a default name for relationships,
do not simply accept this default without due consideration. There may
be some relationships where the default is applicable, but in most cases
you will want to explicitly name the relationship. Be sure that you have
provided a verb phrase for both directions in the relationship.
This is the end of lab #2#4.
==============================================
CIS 336 iLab 3 Building the Physical
FOR MORE CLASSES VISIT
www.cis336study.com
CIS-336: Lab 3: Building the Physical
LAB OVERVIEW
Scenario and Summary
The lab for this week addresses taking a logical database design (data
model) and transforming it into a
physical model (tables, constraints, and relationships). As part of the lab,
you will need to download the
zip file titled CIS336Lab3Files from Doc Sharing. This zip file contains
the ERD, Data Dictionary, and test
data for the tables you create as you complete this exercise.
Your job will be to use the ERD Diagram found below as a guide to
define the table structures and
constraints using both CREATE TABLE and ALTER TABLE
statements. Once this has been done, you will
need to write the INSERT INTO TABLE statements to insert the data
provided into the table. The data
should verify that the constraints you have created are valid and define
the correct referential and data
integrity constraints asked for. Lastly, you will write SELECT
statements to query the tables and verify
the data was populated. Please use exactly the data provided, without
addition, deletion, or alteration
except as directed, as your results may be evaluated against expected
results generated using this exact
data set.
Narrative/Case Study
For this lab, you will be creating SQL statements to build a series of
relational tables, using SQL CREATE
statements in a script file format for the Student Database. You will then
populate those tables through
the use of INSERT statements with sample data.
You will need to create a script file and name it YourName_Lab3.txt
containing the following code.
1. The drop table statements listed later in the specifications of this lab.
2. The CREATE TABLE statements required to build the six tables.
3. The INSERT statements necessary to insert all of the sample data.
4. Six 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 ERD Diagram which
follows, and the exact data to be inserted into each table, which may be
found via the Doc Sharing tab
on the course website.
The following guidelines are being provided to help assist you in
creating your script file.
· Use the names for the tables and columns as listed in the ERD. Do not
change them as it will
affect your grade.
· Creating Constraints
o Create all NOT NULL constraints as indicated in the ERD.
o Create all PK constraints as indicated in the ERD.
o Create all FK constraints as indicated in the ERD.
· Create all of the tables and all of the constraints before populating any
of the tables with data.
· Because FK constraints will be in place when the insert statements are
executed, you will need
to consider carefully which tables must be created before others in order
to ensure that FK
constraints are not violated.
· The COURSE table has a self-referencing FK constraint. Specifically,
some courses have
prerequisite courses. Consequently, the record for a course possessing a
prerequisite course
cannot be successfully inserted into the table unless the record for the
prerequisite course has
already been inserted. This may require you to reorder the insert
statements to resolve FK
violations when loading the table. You may reorder the data provided for
this table, but do not
alter it.
· The data for one table intentionally contains a record containing an FK
constraint that is not
resolved by a record in the parent table. This orphaned record has been
included as an exercise
for you to find. Because this record has an unreconciled FK constraint, it
cannot be successfully
inserted. You will need to delete or comment out the insert statement for
this one record in
order to produce a script that runs without errors.
· Aside from reordering the data for the COURSE table as necessary,
and commenting
out/deleting the ONE record whose FK dependency cannot be resolved
by the data provided,
you are NOT to modify, add to, or delete from the data provided. Your
SQL script must produce
tables containing data identical to the expected solution set, or points
will be deducted.
· ALL character strings must be enclosed in single quotes. This includes
alpha strings and
alphanumeric (remember that any formatting within a numeric string
makes it alphanumeric).
· If you are inserting a NULL, do not enclose the word NULL in single
quotes, as this will insert the
word NULL into the row. To insert a null you simply use the word
NULL.
Deliverables
The deliverable for this lab will include the following documents.
1. Your script file. Create this file in Notepad, or another PURE TEXT
editor—NOT Word. Make sure
your name is in a comment area at the top of the script file. Use a double
dash to create a one-
line comment.
–Jane Smith
–Lab 3
2. Your script file must execute without error. It is recommended that
you begin early in the week,
and post any questions to the Q & A discussion in order to produce a
working script by the due
date.
Be sure your name is on all documents and that all documents have been
included in a single zip file for
this week‘s assignments.
Refer to the following ERD in constructing your solution.
Student
PKStudent_ID
Salutation
First_Name
Last_Name
Street_Address
Phone
Employer
Registration_Date
FK1Zip
Enrollment
PK,FK1Section_ID
PK,FK2Student_ID
Enroll_Date
Final_Grade
LAB STEPS
STEP 1: The DROP Statements
A DROP TABLE statement must appear in your script file, prior to the
SQL statements for creating
the table in question. This will allow you to run and re-run your script
file as often as you need to. The
very first time you run your script the table does not exist, so the IF
EXISTS clause causes the statement
to be ignored. Thereafter, the table will be deleted, ensuring that your
CREATE TABLE statement creates
the table fresh and clean, with only the attributes present in the current
revision of the CREATE
statement. Here is an example of one of the six DROP TABLE
statements you will need to create.
DROP TABLE IF EXISTS `ENROLLMENT` ;
STEP 2: The CREATE TABLE Statements
Next, define the CREATE TABLE statements for the six tables that you
are to create based upon the
ERD (provided above) for this lab. Be sure to follow the guidelines
given above on how and where to
create the different types of constraints for each table. This will include
PK, FK, and NOT NULL
constraints.
STEP 3: The INSERT Statements for the Data
The third step is to create the insert statements to insert the sample data
into the tables created in
Step 2. The data for each table is contained in text files, named for the
table whose data it contains.
Modify the format of the data (e.g., date formats and add or eliminate
quote marks) as needed to craft
your insert statements, but do not change the inherent value of the data.
STEP 4: The SELECT Statements
The next step of the lab will be to create the select statements to verify
the data was inserted
correctly. You should have six 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 would be
SELECT * FROM student;
Be sure to save all of the above statements in your script file.
STEP 5: Testing and Verifying Your Script
Now we come to the point of verifying that your script file works by
creating all of the tables and
inserting and selecting all of the data. Your script should execute
without errors, and select the entire
contents of each table in turn. Inspect your query results to ensure that
each column and row from
each of the tables is as expected. Correct and repeat testing of your script
until no errors occur, and the
results match expectations. You may also use the DESCRIBE command
to display the table structure of
each table, and verify that PK and NULL constraints have been properly
created. The SHOW CREATE
TABLE statement is useful for displaying the SQL that would
regenerate a given table, which is a useful
way for checking that FKs have been properly created.
Examples:
DESCRIBE STUDENT;
SHOW CREATE TABLE STUDENT;
This is the end of Lab 3_____
==============================================
CIS 336 iLab 4 Introduction to Select, Insert, Update, and
Delete Statements (only SQL Command, No output)
FOR MORE CLASSES VISIT
www.cis336study.com
CIS336: Lab 4: Introduction to Select, Insert, Update, and Delete
Statements
LAB OVERVIEW
Lab 4 will introduce the various aspects of the SQL select statement and
the methods of retrieving data from the database tables. This lab will
also introduce the fundamentals of updating and deleting records. This
lab may be completed using either DeVry‘sOmnymbus EDUPE-APP lab
environment, or a local copy of the MySQL database running on your
own computer using the OM database tables. The lab will utilize a set of
tables that are represented by the ERD (OM_ERD.docx) and are created
and populated by the script file (create_OM_db.sql). Follow the
instructions in the file CreateOMTables.docx to create your database,
tables, and data.
A few IMPORTANT things to note if using EDUPE MySQL:
**There can be NO SPACES in alias names given to a column. For
example:
Select unit_price as ―Retail Price ― from items; –this does NOT work in
EDUPE MySQL.
Any of the following WILL WORK:
Select unit_price as ―RetailPrice‖ from items;
Select unit_price as ―Retail_Price‖ from items;
Select unit_price as Retail_Price from items;
Select unit_price as RetailPrice from items;
**Any calculated fields MUST be given an alias (and note above NO
SPACES in alias). For example:
select unit_price * 2 from items; –this does NOT work in EDUPE
MySQL
This will work:
select unit_price * 2 as NewPrice from items;
Deliverables
• Lab Report (Answer Sheet) containing both the student-created SQL
command(s) for each exercise, and the output showing the results
obtained. Be sure your name is on the file.
LAB STEPS: Complete each of the exercises below.
1. Write a query that displays a list of all customers showing the
customer first name, last name, and phone number. Sort the results by
customer last name, then first name.
2. Write a query that displays each customer name as a single field in the
format ―firstnamelastname‖ with a heading of Customer, along with
their phone number with a heading of Phone. Use the IN operator to
only display customers in New York, New Jersey, or Washington D.C.
Sort the results by phone number.
3. Write a query that will list all the cities that have customers with a
heading of Cities. Only list each city once (no duplicates) and sort in
descending alphabetical order.
4. Write a query that displays the title of each item along with the price
(with a heading of Original) and a calculated field reflecting the price
with a 25% discount (with a heading of Sale). Display the sale price with
two decimal places using the ROUND function. Sort by price from
lowest to highest.
5. Write a query that displays the customer_first_name,
customer_last_name, and customer_city from the customers table. Use
the LIKE operator to only display customers that reside in any zipcode
beginning with 4.
6. Write a query that displays the order id and order date for any orders
placed from March 1, 2014 through April 30, 2014. Do this WITHOUT
using the BETWEEN clause. Format the date field as Month dd, yyyy
and use a heading of ―Ordered‖.
7. Write a query that displays the order id and order date for any orders
placed during the month of May, 2014. Do this using the BETWEEN
clause. Format the date field as mm/dd/yy and use a heading of
―Ordered‖.
8. Write a query which displays the order id, customer id, and the
number of days between the order date and the ship date (use the
DATEDIFF function). Name this column ―Days‖ and sort by highest to
lowest number of days. Only display orders where this result is 15 days
or more.
9. Write a query which displays the order id, customer id and order date
for all orders that have NOT been shipped, sorted by order date with the
most recent order at the top.
10. The Marketing Department has requested a new report of shipped
orders for which the order was placed on either a Saturday or a Sunday.
Write a query which displays the order id, order date, shipped date,
along with a calculated column labeled ―Order_Day‖ showing the day of
the week the order was placed (use the DAYNAME function). Only
display orders that have shipped and were placed on a Saturday or
Sunday. Sort by order date with most recent orders at the top.
11. Write a query to display the customer last name, phone number, and
fax number but only display those customers that have a fax number.
12. Create a statement to insert a new record into the items table with the
following values:
item_id: 11
title: Ode To My ERD
Artist_id: 15
unit_price: 12.95
Show your INSERT statement along with the results of the following
SELECT query to verify that the insert worked correctly.
select * from items where item_id> 10;
13. Create a statement to update the record inserted in the previous step
to change the unit price of this item to 7.95.
item_id: 11
title: Ode To My ERD
artist: 15
unit_price: 7.95
Show your UPDATE statement along with the results of the following
SELECT query to verify that the insert worked correctly.
select * from items where item_id> 10;
14. Create a statement to delete the entire record that was inserted and
then updated in the previous steps.
Show your DELETE statement along with the results of the following
SELECT query to verify that the insert worked correctly.
select * from items where item_id> 10;
15. Using the SUBSTRING and CONCAT functions, write a query to
display each customer name as a single field in the format ―Jones, Tom‖
with a heading of Customer along with the customer_phone field in a
nicely formatted calculated column named Phone. For example, a record
containing the customer_phone value 6145535443 would be output with
parentheses, spaces, and hyphens, like this: (614) 555-5443. Sort by last
name.
This is the end of Lab 4.
==============================================
CIS 336 iLab 5 Joining Tables
FOR MORE CLASSES VISIT
www.cis336study.com
CIS336: Lab5: Joining Tables
LAB OVERVIEW
Scenario and Summary
Lab 5 will introduce the concept of multi-table JOINS in order to work
with data in two or more related tables simultaneously. This lab may be
completed using either DeVry‘sOmnymbus EDUPE-APP lab
environment, or a local copy of the MySQL database running on your
own computer using the OM database tables. The lab will utilize a set of
tables that are represented by the ERD (OM_ERD.docx) and are created
and populated by the script file (create_OM_db.sql). Follow the
instructions in the file CreateOMTables.docx to create your database,
tables, and data.
A few IMPORTANT things to note if using EDUPE MySQL:
**There can be NO SPACES in alias names given to a column. For
example:
Select unit_price as ―Retail Price ― from items; –this does NOT work in
EDUPE MySQL.
Any of the following WILL WORK:
Select unit_price as ―RetailPrice‖ from items;
Select unit_price as ―Retail_Price‖ from items;
Select unit_price as Retail_Price from items;
Select unit_price as RetailPrice from items;
**Any calculated fields MUST be given an alias (and note above NO
SPACES in alias). For example:
select unit_price * 2 from items; –this does NOT work in EDUPE
MySQL
This will work:
select unit_price * 2 as NewPrice from items;
Deliverables
• Lab Report (Answer Sheet) containing both the student-created SQL
command(s) for each exercise, and the output showing the results
obtained. Be sure your name is on the file.
LAB STEPS: Complete each of the exercises below:
1. Use the JOIN ON syntax to write a query to display the order id, order
date, customer name formatted as a single field (i.e. ―Tom Jones‖) with a
heading of Customer, and customer_city for customers residing in the
state of OHIO. Sort the output to display the newest orders first.
2. Use the JOIN USING syntax to display the order_id, order date, and
shipdate for orders to Karina Lacy that have shipped.
3. Use the implicit join syntax (the WHERE clause) to display the last
name, city, order date and ship date for all orders shipped in 2012.
4. Use any join syntax EXCEPT NATURAL JOIN to list the
customer_first_name and customer_last_name concatenated with an
intervening space as Customer, customer city and state formatted as a
single column in the format of ―city, ST‖ with a heading of Location,
order_id and order date for orders that have not shipped.
5. List the customer name, order date, zipcode for any customer(s)
placing an order for the item titled ‗Etcetera‖.
6. Write a query to list the title and artist of ONLY the items that have
been ordered. Only list each title once.
7. Write a query to list the title and price of all items that have been
ordered by customer Millerton.
8. Write a query to list the last name and order id of customers that
ordered any items by the artist Burt Ruggles?
9. Write a query to display a list of titles along with the artist name.,
sorted by artist name.
10. Write a query to display an invoice for order 693 including the title,
quanty, price, and a calculated column to display the line item subtotal
(quantity times price) with a heading of Subtotal.
11. Display the order id, last name, title , and quantity for any items
where customers have ordered 2 or more of a particular item in an order.
12. The employees table contains a list of employees of a company. An
employee may be managed by another employee. To denote an
employee‘s manager, the employee_id of the manager is entered into the
manager_id field of the employee reporting to that manager. In order to
produce a list of which managers supervise which employees, the table
may be joined to itself using these two attributes (employee_id,
manager_id). This is known as a SELF-JOIN. Use a SELF-JOIN on the
employees table to produce a result containing two columns: the
concatenated last_name and first_name of the manager, and the
concatenated last_name and first_name of the employee. Label the first-
column supervisor, and the second-column employee. Order the output
by the supervisor‘s last_name and first_name.
13. Write a query to display the order id, order date, ship date, and
customer last name for all SHIPPED orders placed on the internet (no
employee id). Show the most recently shipped orders first.
14. Write a query that displays the order id, order date, and employee
name as a single field labeled Employee for each order that an employee
assisted with.
15. Write a query that displays the order id, order date, customer name
as a single field labeled Customer for all orders for the sales rep Thomas
Hardy, sorted by customer last name.
This is the end of Lab 5.
==============================================
CIS 336 iLab7 Working with Views
FOR MORE CLASSES VISIT
www.cis336study.com
CIS-336: Lab7: Working with Views
LAB OVERVIEW
Lab 7 will introduce the concept of database views. This lab
may be completed using either DeVry‘sOmnymbus EDUPE-
APP lab environment, or a local copy of the MySQL database
running on your own computer using the OM database tables.
The lab will utilize a set of tables that are represented by the
ERD (OM_ERD.docx) and are created and populated by the
script file (create_OM_db.sql). Follow the instructions in the file
CreateOMTables.docx to create your database, tables, and data.
A few IMPORTANT things to note if using EDUPE MySQL:
**There can be NO SPACES in alias names given to a column.
For example:
Select unit_price as ―Retail Price ― from items; –this does NOT
work in EDUPE MySQL.
Any of the following WILL WORK:
Select unit_price as ―RetailPrice‖ from items;
Select unit_price as ―Retail_Price‖ from items;
Select unit_price as Retail_Price from items;
Select unit_price as RetailPrice from items;
**Any calculated fields MUST be given an alias (and note
above NO SPACES in alias). For example:
select unit_price * 2 from items; –this does NOT work in
EDUPE MySQL
This will work:
select unit_price * 2 as NewPrice from items;
Deliverables
• Lab Report (Answer Sheet) containing both the student-created
SQL command(s) for each exercise, and the output showing the
results obtained. Be sure your name is on the file.
LAB STEPS: Complete each of the exercises below.
1. Use an ALTER TABLE statement to update the customers
table so that the Primary Key field is an auto-increment field,
then create TWO insert statements to test proper operation,
using your own first and last name for one (and a name of your
choice for the second one), and any data you care to imagine for
the remaining fields.
IMPORTANT NOTE: When using a LOCAL copy of MySQL,
if you attempt to simply issue the ALTER TABLE command
you have composed by itself, you should receive an error similar
to the following (try it for yourself!).
ERROR 1833: Cannot change column ‗customer_id‘: used in a
foreign key constraint ‗orders_fk_customers‘ of table
‗om.orders‘
(Note – EDUPE will not give this error message, however you
should still follow the CORRECT procedure as discussed here
to complete this problem).
The reason for this is that you are attempting to alter data in one
column that has a defined PK:FK relationship to a field in
another table. Referential Integrity rules prevent this. So, how do
you resolve such a problem?
One approach to solving this dilemma is to turn off the foreign
key checks that implement referential integrity rules. However,
the danger here is that other users and processes operating on the
database while these constraints are suspended could create or
modify data in a way that compromises integrity. We can solve
this second problem by preventing other users and processes
from altering the data in the table in which we are working until
we have turned the foreign key checks back on. We therefore
need to construct a script that does the following.
a) Locks the customer table – lock table customers write;
b) Turns off FK checks – set foreign_key_checks = 0;
c) Alters the table to add the auto_increment feature to the PK
field
d) Turns FK checks back on – set foreign_key_checks = 1;
e) Unlocks the customer table – unlock tables;
It is VERY important to consider that altering tables can require
a bit of time for very large tables, and that while the table is
locked, other users and processes cannot operate. Consequently,
this kind of modification should not be done during peak
operating hours in a production operation (as a student in a lab
exercise, working on your own database, you may do this at any
time) but ideally in hours during which the business does not
normally operate. In cases where round-the-clock, high
availability of a database is required, other approaches may be
required. Addressing this problem in a high-availability, high-
demand environment is an advanced topic, study of which is
outside the scope of this course. Use the outline below to
construct your script. Show all commands in your answer sheet
along with the output of the commands.
lock table customers write;
set foreign_key_checks = 0;
– Replace this comment with your ALTER TABLE command to
add the auto_increment feature to the PK field
set foreign_key_checks = 1;
unlock tables;
–statements to insert two rows into the table
–verify auto_increment with a select statement
2. The Vice President of Marketing for your firm wants the
firm‘s sales representatives to be able to directly view and edit
customer details, but only for the state to which a particular sales
representative is assigned. You have suggested that this need can
be addressed with a view. For example, a view could be created
for one particular state, and user account permissions for
accessing that view granted only to sales representatives from
that state. The VP has asked you to quickly create a simple
proof-of-concept demonstrating how this might work. Complete
the following steps:
a. Construct a view on the customers table called
CA_CUSTOMERS that consists of all data about customers that
live in California.
b. Display the data using this view to verify that only customers
that reside in California are visible.
c. Prove that It is possible to add or update records through this
view by updating the record for Karina Lacy to change the
spelling of Karina‘s last name to Lacie.
d. Display the data using the customer table to verify that the
change has been made.
Show all commands in your answer sheet along with the output
of the commands.
3. The Senior Customer Service Manager has requested the
ability to create a report at any time that will show shipped
orders that took some specified number of days to fulfill.
a. Create a view named SHIPPING_TIME that lists only
customer_first_name, customer_last_name, order_date,
shipped_date, and the calculated field days_to_fulfill (use the
DATEDIFF function) showing the number of days between
when the customer placed the order and when it was shipped.
Show the data from this view.
Now let‘s do some queries by adding sorting and filters USING
THIS VIEW, WITHOUT CHANGING IT.
b. Use the view to display the data sorted by highest to lowest
days to ship
c. Use the view to display only the orders that took less than 10
days to ship.
d. Use the view to display only the orders that took more than 30
days to ship.
4. Queries that require joins and aggregate functions can be
easier to construct when using a view as a ―temporary‖ table.
Consider a report to show total sales by artist.
a. First create a view called SalesData that displays the order_id,
item_id, the calculated field ItemTotal (which is quantity times
price), the title and artist_id.
b. Display the data in the SalesData view sorted by artist_id.
Does this help you to ―visualize‖ how to group the data to create
the totals?
c. Create a query USING THIS VIEW and the appropriate
aggregate function to display artist_id and the total sales for
each artist.
d. Now join to the artist table in order to display the artist_name
along with the total sales.
5. Now use this same method to display the total sales per
customer.
a. Create a view called SalesData with the appropriate data. At a
minimum you will need customer_id and the calculated item
total. DO NOT use the customer table in this view, it will be
joined later.
b. Display the data in your view sorted by customer_id. Does
this help you to ―visualize‖ how to group the data to create the
totals?
c. Create a query USING THIS VIEW and the appropriate
aggregate function to display customer_id and the total sales for
each customer.
d. Now join to the customer table in order to display the
customer_name as a single field named Customer along with the
total sales. Sort the report by Total sales in descending order.
This is the end of Lab 7.
==============================================
CIS 336 Quiz 1 (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
(TCO 3) Normalization works through a series of stages called normal
forms. Typically _________ stages must be completed before a table can
be considered normalized.
(TCO 3) The conflicts between design efficiency, information
requirements, and processing speed are often resolved through
(TCO 3) The PK must uniquely identify each entity instance. A primary
key must be able to guarantee unique values. It cannot contain nulls.
This rationale belongs to
(TCO 9) The SQL command that lets you insert data into a table, one
row at a time, is _____________.
(TCO 4) Which command is used to restore the table's contents to their
default values?
(TCO 4) Which of the following SQL commands would alter the table
DEVRY and add a foreign key that references the CITY table?
(TCO 4) The SQL command that lets you save your work to disk, is
___________
(TCO 9) If the INSERT INTO command is used to insert data values
that violate an existing constraint in a table, which of the following will
happen?
(TCO 3) Explain under what circumstances a partial dependency can
exist in a database.
==============================================
CIS 336 Quiz 2 (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
(TCO 2) Explain what a composite attribute is
(TCO 1) Data constitutes the building blocks of
(TCO 1) Successful database design is first and foremost based on
_____________ requirements.
(TCO 1) The lowest level in a database hierarchy is the ____________
or value as it is often referred
(TCO 2) The term _____________ design is used to refer to the task of
creating the conceptual data model represented by an Entity Relationship
Diagram (ERD).
(TCO 2) Within a table, the primary key must be unique so that it will
identify each row. When this is the case, the table is said to exhibit
___________.
(TCO 2) A field that consists of data values that can be used for
arithmetic procedures is a _________ type field.
(TCO 2) A relationship is an association between ___________
(TCO 5) The _____________ model represents a global view of the
data.
(TCO 5) In Crow's Foot notation, a forked end means
==============================================
CIS 336 Quiz 3 (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
(TCO 7) Which of the following types of columns will automatically
right-align the data when it is displayed?
(TCO 7) Which of the following SQL statements will display the profit
generated by each book currently stored in the BOOKS table? (You do
not need to see the table structure for this question)
(TCO 7) Which of the following will display the new retail price of each
book as 20 percent more than it originally cost?
(TCO 7) Which of the following operators would be most appropriate to
determine whether or not the retail price of a book is at least $24.00?
(TCO 7) The ______________________ comparison operator is used to
indicate that a data value must fall within a range of values to be
included in the query results.
(TCO 7) Based upon the contents of the BOOK_ORDER table shown
below, which of the following queries will display all orders that were
not shipped for at least three days after the order was received?
(TCO 7) ANSI-standard SQL allows the use of a special operator in
conjunction with WHERE clause. A special operator used to check
whether an attribute matches one from a subquery is_______.
(TCO 7) A ____ occurs when a relationship is improperly or
incompletely identified and, therefore, is represented in a way that is not
consistent with the real world.
(TCO 7) The ______________________ comparison operator is used to
search for values which are not NULL.
TCO 7) You want to write a query that will return the customer number,
first and last name from the book_order table (shown below) for all
customers who have a P.O. Box and who live in either Trenton or
Chicago. Write the query that will accomplish this task.
==============================================
CIS 336 Quiz 4 (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
(TCO 8) If a Cartesian join is used to link table A which contains five
rows to table B which contains eight rows, there will be _______ rows
in the results.
(TCO 8) Which of the following statements will produce the value 21.1?
(TCO 8) Which of the following format elements will display
insignificant leading zeros?
(TCO 8) Oracle‘s pseudo table used only for cases where a table is not
really needed is _________?
(TCO 7) Using the BOOK_CUSTOMER and BOOK_ORDER tables
shown below for reference which SQL statement will return the same
results as the following SQL statement?
(TCO 7) A table alias or qualifier cannot be assigned in the FROM
clause of which type of join?
(TCO 7) The _______ query joins a table to itself using aliases to
distinctly identify each instance of the table.
(TCO 7) Explain the difference between an inner join and an outer join.
==============================================
CIS 336 Quiz 5 (Devry)
FOR MORE CLASSES VISIT
www.cis336study.com
(TCO 6) Which of the following keywords is used to remove a row in a
table?
(TCO 6) When using the ALTER TABLE...DROP COLUMN
command, which of the following is NOT correct?
(TCO 6) Which of the following commands will add a new column
named FIRSTORDERDATE to the CUSTOMERS table to store the date
that the customer first placed an order with the company?
(TCO 8) Which of the following is NOT a valid statement?
(TCO 8) Based on the contents of the BOOKS table shown below,
which of the following SQL statements will return the total profit
generated by books in the COOKING category?
(TCO 8) Which comparison operator evaluates a subquery and if it
returns false, will not execute the calling query?
(TCO 8) The following SQL statement contains which type of
subquery?
(TCO 9) If the _________ clause of the UPDATE command is omitted,
then all the rows in the specified table will be changed.
(TCO 9) Which of the following is not a valid SQL command?
(TCO 9) Based on the contents of the PROMOTION table, which of the
following commands will delete only the row for the Free Bookmark
from the table?
(TCO 8) In using group functions we cannot place a group function in a
WHERE clause. Explain how the WHERE clause and HAVING clause
similar and why you can use the HAVING with a group function but not
a WHERE clause.
==============================================
CIS 336 Week 2 Quiz (New)
FOR MORE CLASSES VISIT
www.cis336study.com
Question 1. (TCO 1) Raw facts, such as a telephone number, a
birth date, and a customer name, are also referred to as _____
Question 2. (TCO 1) The DBMS allows you to extrapolate
information from your data by using a _____
Question 3. (TCO 1) A database row (record) consists of
_____
Question 4. (TCO 2) In Oracle, a _____ is automatically
constrained to be unique and not null.
Question 5. (TCO 2) A verb associating two nouns in a
business rule usually translates to a(n) ___ in the data model.
Question 6. (TCO 2) In a relationship, when a primary key
from one table is also defined in a second table, the field is referred to as
a _____ in the second table.
Question 7. (TCO 2) In a relational database, each table must
have _____
Question 8. (TCO 5) The product of a logical model is the
entity relationship diagram, also known as a _____
==============================================
CIS 336 Week 3 Quiz (New)
FOR MORE CLASSES VISIT
www.cis336study.com
Question 1. (TCO 3) When designing a database, you should
_____
Question 2. (TCO 3) A table that is in 1NF and includes no
partial dependencies only is said to be in _____
Question 3. (TCO 3) (TCO 3) A table is not in 1NF if
_______________.
Question 4. (TCO 9) All of following are examples of DML
commands except _____
Question 5. (TCO 4) Which of the following is not considered
a database object?
Question 6. (TCO 4) In Oracle, the DEFAULT constraint is
used to _____
Question 7. (TCO 4) The SQL command that lets you save
your work to disk, is _____
Question 8. (TCO 9) Which of the following SQL statements
would insert a line of data into the DEVRY table and supply a NULL
value for the Student_city column?
==============================================
CIS 336 Week 4 Quiz (New)
FOR MORE CLASSES VISIT
www.cis336study.com
Question 1. (TCO 7) Which of the following types of columns
will automatically right-align the data when it is displayed?
Question 2. (TCO 7) Which of the following symbols can be
used to denote that any and all characters following the sign are eligible
when used with LIKE?
Question 3. (TCO 7) Based upon the contents of the BOOKS
table shown below, which of the following is a valid SQL statement?
Question 4. (TCO 7) Which of the following operators would
be most appropriate to determine whether or not the retail price of a
book is at least $24.00?
Question 5. (TCO 7) Based upon the contents of the
BOOK_ORDER table shown below, which of the following SQL
statements will list all orders placed by customer# 1020 that have not yet
been shipped?
Question 6. (TCO 7) Based upon the contents of the
BOOK_ORDER table shown below, which of the following queries will
display all orders shipped between April 4, 2003 and April 5, 2003?
Question 7. ((TCO 7) The ____ comparison operator is used
to search for values that are not NULL.
Question 8. (TCO 7) You want to write a SQL query that lists
all employees in the EMP table whose last names in the EMP_LNAME
column start with Smith, including values such as Smithfield. What is
the correct statement?
==============================================
CIS 336 Week 5 Quiz (New)
FOR MORE CLASSES VISIT
www.cis336study.com
Question 1. (TCO 8) The ____ set operator in SQL combines
rows from two queries and returns only the values that are common
between the two sets.
Question 2. (TCO 8) Which SQL function converts a value to
a particular string format?
Question 3. (TCO 8) Based upon the contents of the
BOOK_ORDER table shown below, which of the following SQL
statements will display only those orders shipped to the zip code zone
that begins with 323?
Question 4. (TCO 8) Oracle‘s pseudo table used only for
cases where a table is not really needed is _____
Question 5. (TCO 7) Using the BOOK_CUSTOMER and
BOOK_ORDER tables shown below for reference, which SQL
statement will return the first and last name of each customer who's
order has not yet shipped?
Question 6. (TCO 7) A table alias or qualifier cannot be
assigned in the FROM clause of which type of join?
Question 7. (TCO 7) A(n) ____ join returns not only the rows
matching the join condition (that is, rows with matching values in the
common columns) but also the rows with unmatched values.
Question 8. (TCO 7) Which statement will display the date in
this format:
==============================================
CIS 336 Week 6 Quiz (New)
FOR MORE CLASSES VISIT
www.cis336study.com
Question 1. (TCO 6) Which of the following
keywords can be used to change the size, datatype, or default
value of an existing column?
Question 2. (TCO 9) If the _____ clause of the
UPDATE command is omitted, then all the rows in the specified
table will be changed.
Question 3. (TCO 6) Which of the following
commands will increase the size of the CITY column in the
CUSTOMERS table from 12 to 20 and increase size of the
Question 4. (TCO 8) Based upon the contents of the
BOOKS table shown below, which of the following SQL
statements will return the number of different categories
contained in the table?
Question 5. (TCO 9) Which of the following is not a
valid SQL command?
Question 6. (TCO 8) Based on the contents of the
BOOKS table shown below, which of the following SQL
statements will return the total profit generated by books in the
COOKING category?
Question 7. (TCO 8) Before the COMMIT command
is used, you can retrieve deleted records by using the _____
command.
Question 8. (TCO 8)Based on the contents of the
BOOK_ORDER table shown below, which of the following
SQL statements will list the order number and customer number
for the most recent orders in the system?
Question 7. (TCO 8) Before the COMMIT command
is used, you can retrieve deleted records by using the _____
command.
Question 8. (TCO 8)Based on the contents of the
BOOK_ORDER table shown below, which of the following
SQL statements will list the order number and customer number
for the most recent orders in the system?
==============================================
CIS336 iLab 6 Group Functions and Subqueries
FOR MORE CLASSES VISIT
www.cis336study.com
CIS336: Lab 6: Group Functions and Subqueries
LAB OVERVIEW
Scenario and Summary
Lab 6 will introduce the concept of group functions and subqueries to
meet more complex report requirements. This lab may be completed
using either DeVry‘sOmnymbus EDUPE-APP lab environment, or a
local copy of the MySQL database running on your own computer using
the OM database tables. The lab will utilize a set of tables that are
represented by the ERD (OM_ERD.docx) and are created and populated
by the script file (create_OM_db.sql). Follow the instructions in the file
CreateOMTables.docx to create your database, tables, and data.
A few IMPORTANT things to note if using EDUPE MySQL:
**There can be NO SPACES in alias names given to a column. For
example:
Select unit_price as ―Retail Price ― from items; –this does NOT work in
EDUPE MySQL.
Any of the following WILL WORK:
Select unit_price as ―RetailPrice‖ from items;
Select unit_price as ―Retail_Price‖ from items;
Select unit_price as Retail_Price from items;
Select unit_price as RetailPrice from items;
**Any calculated fields MUST be given an alias (and note above NO
SPACES in alias). For example:
select unit_price * 2 from items; –this does NOT work in EDUPE
MySQL
This will work:
select unit_price * 2 as NewPrice from items;
Deliverables
• Lab Report (Answer Sheet) containing both the student-created SQL
command(s) for each exercise, and the output showing the results
obtained. Be sure your name is on the file.
LAB STEPS: Complete each of the exercises below.
1. Write a query to determine the total number of items on each order.
Display the order_id and the total with a heading of TotalItems (note no
spaces). Filter to only display information for order_id of 600 or higher.
2. Re-do query 1 but filter to only show those orders with more than 2
items ordered. Sort by the number of items ordered, lowest to highest.
3. The order_details table has a quantity for each item ordered. Show the
total amount charged for each item on the order (quantity times price).
Display order_id, the item id, the unit price, the quantity times price of
the item labeled as ―Itemtotal‖ (note NO spaces). Sort by order id and
filter to only display those order ids between 400 and 700.
4. Write a query to display the total amount for each order: show the
order id and total. Sort by descending order on the total and only display
orders with a total of $40 or more.
5. Re-do query 4 but show the customer name for each order (formatted
as a single field with heading of Customer) along with the city, order id
and total. Filter to only display customers that live in California. Sort by
city.
6. Display the total amount of sales per item. Show title, total quantity
sold with a heading of Quantity, total sales with a heading of
―TotalSales‖ (not NO space). Sort by highest to lowest total.
7. Display the total sales for each customer: show customer name (as
single field) with a heading of Cutomer and total. Sort lowest to highest
total. Filter to only display customers with $50 or more in total orders.
8. Use subqueries to determine which (artist) had the item ordered in
highest quantity on an order? First determine the highest quantity on any
order, then determine the item number associated with it, then display
the artist.
9. Display the total sales by artist: show artist name, total. Sort highest to
lowest.
10. USE A SUBQUERY to Increase price of all items by ‗No Rest for
the Weary‘ by 10%. If working in MySQl you will need to disable safe
mode. Show prices before and after. Rollback after.
11. USE A SUBQUERY to display names of customers that have
unshipped orders.
12. Display the total amount of sales made to customers in NY
13. USE A SUBQUERY to list the items (title and artist) of items that
have never been ordered
14. Show the order history for Samuel Jacobsen. Display the order id,
order date, ship date, and total.
15. Show the total amount of sales per sales rep. Display the employee
name as a single field along with the total sales, sorted by highest to
lowest sales.
This is the end of Lab 6.
==============================================

More Related Content

What's hot

Dbms narrative question answers
Dbms narrative question answersDbms narrative question answers
Dbms narrative question answersshakhawat02
 
BIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comBIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comagathachristie256
 
BIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comBIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comagathachristie241
 
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comBIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comthomashard72
 
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comBIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comKeatonJennings120
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-bookVipul Wankar
 
Types of sql commands by naveen kumar veligeti
Types of sql commands by naveen kumar veligetiTypes of sql commands by naveen kumar veligeti
Types of sql commands by naveen kumar veligetiNaveen Kumar Veligeti
 
Normalization
NormalizationNormalization
Normalizationochesing
 
CIS 336 Inspiring Innovation -- cis336.com
CIS 336 Inspiring Innovation -- cis336.comCIS 336 Inspiring Innovation -- cis336.com
CIS 336 Inspiring Innovation -- cis336.comkopiko105
 
BIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.comBIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.comagathachristie179
 
BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
 BIS 245 OUTLET Inspiring Innovation--bis245outlet.com BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
BIS 245 OUTLET Inspiring Innovation--bis245outlet.comwilliamwordsworth45
 
Dbms question
Dbms questionDbms question
Dbms questionRicky Dky
 
BIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comBIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comagathachristie291
 

What's hot (18)

SQL for ETL Testing
SQL for ETL TestingSQL for ETL Testing
SQL for ETL Testing
 
Dbms narrative question answers
Dbms narrative question answersDbms narrative question answers
Dbms narrative question answers
 
Sq lite module8
Sq lite module8Sq lite module8
Sq lite module8
 
BIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comBIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.com
 
BIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comBIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.com
 
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comBIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
 
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comBIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-book
 
Sq lite module6
Sq lite module6Sq lite module6
Sq lite module6
 
Types of sql commands by naveen kumar veligeti
Types of sql commands by naveen kumar veligetiTypes of sql commands by naveen kumar veligeti
Types of sql commands by naveen kumar veligeti
 
Viva voce
Viva voceViva voce
Viva voce
 
Normalization
NormalizationNormalization
Normalization
 
12 SQL
12 SQL12 SQL
12 SQL
 
CIS 336 Inspiring Innovation -- cis336.com
CIS 336 Inspiring Innovation -- cis336.comCIS 336 Inspiring Innovation -- cis336.com
CIS 336 Inspiring Innovation -- cis336.com
 
BIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.comBIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.com
 
BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
 BIS 245 OUTLET Inspiring Innovation--bis245outlet.com BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
 
Dbms question
Dbms questionDbms question
Dbms question
 
BIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comBIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.com
 

Similar to CIS 336 STUDY Education Planning--cis336study.com

It 610 colorado university, RELATIONAL DATABASE MANAGEMENT SYSTEMS IT610 DQ1 ...
It 610 colorado university, RELATIONAL DATABASE MANAGEMENT SYSTEMS IT610 DQ1 ...It 610 colorado university, RELATIONAL DATABASE MANAGEMENT SYSTEMS IT610 DQ1 ...
It 610 colorado university, RELATIONAL DATABASE MANAGEMENT SYSTEMS IT610 DQ1 ...Willy James
 
BIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comBIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comkopiko33
 
BIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.comBIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.comagathachristie204
 
CIS 336 (DEVRY) Entire Course NEW
CIS 336 (DEVRY) Entire Course NEWCIS 336 (DEVRY) Entire Course NEW
CIS 336 (DEVRY) Entire Course NEWshyamuopuop
 
CIS 336 Wonderful Education--cis336.com
CIS 336 Wonderful Education--cis336.comCIS 336 Wonderful Education--cis336.com
CIS 336 Wonderful Education--cis336.comJaseetha16
 
75629 Topic prevention measures for vulneranbilitiesNumber of.docx
75629 Topic prevention measures for vulneranbilitiesNumber of.docx75629 Topic prevention measures for vulneranbilitiesNumber of.docx
75629 Topic prevention measures for vulneranbilitiesNumber of.docxsleeperharwell
 
CMIS 330 WEEK 4 SDD
CMIS 330 WEEK 4 SDDCMIS 330 WEEK 4 SDD
CMIS 330 WEEK 4 SDDHamesKellor
 
CIS 515 Effective Communication - tutorialrank.com
CIS 515  Effective Communication - tutorialrank.comCIS 515  Effective Communication - tutorialrank.com
CIS 515 Effective Communication - tutorialrank.comBartholomew22
 
Devry cis 321 week 4 milestone 4 part 1
Devry cis 321 week 4 milestone 4 part 1Devry cis 321 week 4 milestone 4 part 1
Devry cis 321 week 4 milestone 4 part 1uopassignment
 
CIS 111 STUDY Introduction Education--cis111study.com
CIS 111 STUDY Introduction Education--cis111study.comCIS 111 STUDY Introduction Education--cis111study.com
CIS 111 STUDY Introduction Education--cis111study.comclaric262
 
CIS 111 STUDY Knowledge Specialist--cis111study.com
CIS 111 STUDY Knowledge Specialist--cis111study.comCIS 111 STUDY Knowledge Specialist--cis111study.com
CIS 111 STUDY Knowledge Specialist--cis111study.comchrysanthemu86
 
CIS 111 STUDY Inspiring Innovation--cis111study.com
CIS 111 STUDY Inspiring Innovation--cis111study.comCIS 111 STUDY Inspiring Innovation--cis111study.com
CIS 111 STUDY Inspiring Innovation--cis111study.comKeatonJennings90
 
CIS 111 STUDY Education Your Life--cis111study
CIS 111 STUDY Education Your Life--cis111studyCIS 111 STUDY Education Your Life--cis111study
CIS 111 STUDY Education Your Life--cis111studythomashard44
 
CIS 111 STUDY Education Planning--cis111study.com
CIS 111 STUDY Education Planning--cis111study.comCIS 111 STUDY Education Planning--cis111study.com
CIS 111 STUDY Education Planning--cis111study.comagathachristie299
 
PURPOSE of the project is Williams Specialty Company (WSC) reque.docx
PURPOSE of the project is Williams Specialty Company (WSC) reque.docxPURPOSE of the project is Williams Specialty Company (WSC) reque.docx
PURPOSE of the project is Williams Specialty Company (WSC) reque.docxamrit47
 
PROG3040 Assignment 1 – Fall 2013 Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docxPROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013 Glenn Paulley – 2A605, x25.docxwkyra78
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallssam2sung2
 

Similar to CIS 336 STUDY Education Planning--cis336study.com (20)

It 610 colorado university, RELATIONAL DATABASE MANAGEMENT SYSTEMS IT610 DQ1 ...
It 610 colorado university, RELATIONAL DATABASE MANAGEMENT SYSTEMS IT610 DQ1 ...It 610 colorado university, RELATIONAL DATABASE MANAGEMENT SYSTEMS IT610 DQ1 ...
It 610 colorado university, RELATIONAL DATABASE MANAGEMENT SYSTEMS IT610 DQ1 ...
 
BIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comBIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.com
 
BIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.comBIS 245 Redefined Education--bis245.com
BIS 245 Redefined Education--bis245.com
 
CIS 336 (DEVRY) Entire Course NEW
CIS 336 (DEVRY) Entire Course NEWCIS 336 (DEVRY) Entire Course NEW
CIS 336 (DEVRY) Entire Course NEW
 
CIS 336 Wonderful Education--cis336.com
CIS 336 Wonderful Education--cis336.comCIS 336 Wonderful Education--cis336.com
CIS 336 Wonderful Education--cis336.com
 
Linq to sql
Linq to sqlLinq to sql
Linq to sql
 
75629 Topic prevention measures for vulneranbilitiesNumber of.docx
75629 Topic prevention measures for vulneranbilitiesNumber of.docx75629 Topic prevention measures for vulneranbilitiesNumber of.docx
75629 Topic prevention measures for vulneranbilitiesNumber of.docx
 
CMIS 330 WEEK 4 SDD
CMIS 330 WEEK 4 SDDCMIS 330 WEEK 4 SDD
CMIS 330 WEEK 4 SDD
 
CIS 515 Effective Communication - tutorialrank.com
CIS 515  Effective Communication - tutorialrank.comCIS 515  Effective Communication - tutorialrank.com
CIS 515 Effective Communication - tutorialrank.com
 
Devry cis 321 week 4 milestone 4 part 1
Devry cis 321 week 4 milestone 4 part 1Devry cis 321 week 4 milestone 4 part 1
Devry cis 321 week 4 milestone 4 part 1
 
CIS 111 STUDY Introduction Education--cis111study.com
CIS 111 STUDY Introduction Education--cis111study.comCIS 111 STUDY Introduction Education--cis111study.com
CIS 111 STUDY Introduction Education--cis111study.com
 
CIS 111 STUDY Knowledge Specialist--cis111study.com
CIS 111 STUDY Knowledge Specialist--cis111study.comCIS 111 STUDY Knowledge Specialist--cis111study.com
CIS 111 STUDY Knowledge Specialist--cis111study.com
 
Sq lite module2
Sq lite module2Sq lite module2
Sq lite module2
 
CIS 111 STUDY Inspiring Innovation--cis111study.com
CIS 111 STUDY Inspiring Innovation--cis111study.comCIS 111 STUDY Inspiring Innovation--cis111study.com
CIS 111 STUDY Inspiring Innovation--cis111study.com
 
CIS 111 STUDY Education Your Life--cis111study
CIS 111 STUDY Education Your Life--cis111studyCIS 111 STUDY Education Your Life--cis111study
CIS 111 STUDY Education Your Life--cis111study
 
CIS 111 STUDY Education Planning--cis111study.com
CIS 111 STUDY Education Planning--cis111study.comCIS 111 STUDY Education Planning--cis111study.com
CIS 111 STUDY Education Planning--cis111study.com
 
PURPOSE of the project is Williams Specialty Company (WSC) reque.docx
PURPOSE of the project is Williams Specialty Company (WSC) reque.docxPURPOSE of the project is Williams Specialty Company (WSC) reque.docx
PURPOSE of the project is Williams Specialty Company (WSC) reque.docx
 
Dba2 spec
Dba2 specDba2 spec
Dba2 spec
 
PROG3040 Assignment 1 – Fall 2013 Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docxPROG3040 Assignment 1 – Fall 2013    Glenn Paulley – 2A605, x25.docx
PROG3040 Assignment 1 – Fall 2013 Glenn Paulley – 2A605, x25.docx
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
 

Recently uploaded

How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 

Recently uploaded (20)

LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 

CIS 336 STUDY Education Planning--cis336study.com

  • 1. CIS 336 Final Exam (July,2019) FOR MORE CLASSES VISIT www.cis336study.com Question 1. 1. (TCO 1) A DBMS performs several important functions that guarantee the integrity and consistency of the data in the database. Which of the following is NOT one of those functions? Question 2. 2. (TCO 1) A relational DBMS provides protection of the _____ through security, control, and recovery facilities. Question 3. 3. (TCO 2) A relationship is an association between _____ ============================================== CIS 336 Final Exam 1 (Devry) FOR MORE CLASSES VISIT www.cis336study.com 1. (TCO 1) Most DBMS are referred to as _____________database management systems. (Points : 4) elemental linked
  • 2. hierarchical relational 2. (TCO 1) Data constitutes the building blocks of _____________. (Points : 4) information processing applications programming ============================================== CIS 336 Final Exam 2 (Devry) FOR MORE CLASSES VISIT www.cis336study.com 1. (TCO 1) Most DBMS are referred to as _____________database management systems. (Points : 4) elemental linked hierarchical
  • 3. relational 2. (TCO 1) A relational DBMS provides protection of the _______________________ through security, control, and recovery facilities. (Points : 4) user network system database ============================================== CIS 336 Final Exam 3 (Devry) FOR MORE CLASSES VISIT www.cis336study.com 1. (TCO 2) Explain what physical independence means. (Points : 15) 2. (TCO 8) Sally wants to query the EMP table and determine how many of the employees live in each of the cities the company has factories in. She writes the following query but it does not work. What is wrong with the way the query is constructed? 3. (TCO 3) Explain in what two specific cases presented in the text composite primary keys are particularly useful. (Points : 15)
  • 4. 4. (TCO 7) How are comparisons done on character string data in a queries WHERE clause, and why would this be especially useful in comparing certain attributes? (Points : 15) ============================================== CIS 336 Final Exam 4 (Devry) FOR MORE CLASSES VISIT www.cis336study.com 1. (TCO 7) For every order, list the order number, order date, part number, part description, and item class for each part that makes up the order. 2. (TCO 8) Write a query that will display the customer number, last name, and first name for every customer I whose first name begins with the letter "D". 2. (TCO 8) Write a query that will display the earliest date an order was placed. ============================================== CIS 336 Final Exam 4 Sets of Answers (Devry)
  • 5. FOR MORE CLASSES VISIT www.cis336study.com CIS 336 Final Exam 4 Sets of Answers ============================================== CIS 336 Group Project FOR MORE CLASSES VISIT www.cis336study.com This project is designed to touch all aspects of the fundamental concepts of database design and logical data modeling covered during the class. Each student will be responsible for designing, developing, and demonstrating the functionality of a database created based on a set of business specifications that you create. At the end of the session, each student will submit a report that includes the logical and physical design of the database and demonstrates the database's ability to deliver meaningful reports. All aspects of the project will be covered during the week or weeks prior to a deliverable, and each task deliverable in the project will be supported through the exercises and labs done in the course.
  • 6. Guidelines You will create a proposal for a commerce business of your choosing. This can be an actual or fictional business that sells products and/or services. You will determine the business rules and report requirements. Entities that must be included in your model are the following. Customer Product (or Service) Order Project Deliverables This task is broken down into four deliverables. · Task 0 · Task 1 · Task 2 · Task 3 Remember that this is a work in progress and in all likelihood, you will have to make numerous changes to your tables and schema as you go along. These changes are to be expected and are a normal part of the database design and implementation process. Please refer to the sections below for details regarding deliverables for each task.
  • 7. Task 0 The first task is to create your business narrative. Some of the questions that you should address include (but are not limited to) the following. · What is the name of your business? · Who will be the users of the system (managers, employees, customers)? · What product(s) and or service(s) does it sell? Be specific. · Who are the customers? What is the customer base? · What sales and distribution channels are used? · How are payments made? · Are products delivered or shipped to customers in some way? · Are sales reps involved? Are they paid on commission? · What type of reports are needed by the business? Please include as much detail as possible in order to provide a foundation for Task 1. Submit your proposal as a Word document. Note that this proposal may be revised in the coming weeks as your understanding of the database modeling process grows. Task 1 Develop a detailed logical model of your database based on your business scenario submitted for Task 0. Your data model will include an
  • 8. entity-relationship diagram (ERD) developed with Microsoft Visio or MySQL and a data dictionary (DD) developed with Microsoft Excel. Note that your deliverables each week include any revisions to the previous task. Submit your Task 1 deliverable as a zip file including the following. · Task 0 proposal (with any revisions or updates) · Your ERD copied to a Word document that fits on a single 8 x 10 page · Your DD (Excel file) Task 2 First, make sure to make any necessary revisions to your logical model based on Task 1 feedback. Using MySQL, write the statements to develop a physical model of your database by creating the tables and constraints based on your Task 1 logical model. Be sure to use your ERD and data dictionary and create all constraints appropriately. Once your tables are created, you will populate them with data using MySQL statements to insert records into the database. You should insert a minimum of five records into each table and more where necessary to ensure that the data in the database is sufficient to allow for each of your reports to be tested. The result will be a script file that includes statements to · DROP all tables;
  • 9. · CREATE all tables with constraints; · INSERT data into all tables; and · SELECT data from all tables to show the data in each table. Name this file yourname_task2.txt. Also create a Word document that shows the structure of each table and the data in each of your tables (copy and paste from MySQL). Name this file yourname_tables.docx. Note that your deliverables each week include any revisions to a previous task. Submit your Task 2 deliverable as a zip file including the following. · Task 0 proposal (with any revisions) · Your Task 1 ERD (with any revisions) · Your Task 1 DD (with any revisions) · Your Task 2 script file to create and populate tables (yourname_task2.txt) · A Word document showing all tables and data (yourname_tables.docx) Task 3 Your final task is to use your tables for an update and for reports. There are two requirements.
  • 10. 1. You will demonstrate an update that includes two tables and uses a subquery. Make sure to prove that your update executed correctly by showing data in the tables before and after the update. 2. You will also develop at least four meaningful reports. One must include a join, one must use a subquery, and one must use an aggregate function. You need to describe the business requirement of the update and each report. Note that numeric PK values are not often meaningful to a person looking at the report. You will create a script file that has each of the queries called yourname_task3.txt. You will also document the results of this task in a Word document called yourname_reports.docx to show the result of each query. For the update and each report, · describe the update and report requirement; · show the query; and · show the result of the query. Include a final section for Conclusions and Lessons Learned regarding the project.Note that your deliverables each week include any revisions to a previous task.Submit your Task 3 deliverable as a zip file including the following. · Task 0 proposal (with any revisions) · Your Task 1 ERD (with any revisions) · Your Task 1 DD (with any revisions) · Your Task 2 script file to create and populate tables (with any revisions)
  • 11. · A Word document showing all tables and data (with any revisions) · Your Task 3 script file with update and reports (yourname_task3.txt) · A Word file with results of Task 3 and lessons learned (yourname_reports.docx) ============================================== CIS 336 iLab 1 Normal Forms and Entity Relationship Diagrams FOR MORE CLASSES VISIT www.cis336study.com CIS336 Lab 1: Normal Forms and Entity Relationship Diagrams Introduction In this exercise, you will analyze a de-normalized data set presented in the form of a spreadsheet. You will next construct a series of dependency diagrams, transforming the evolving data model from First Normal Form (1NF), to Second Normal Form (2NF), and finally to Third Normal Form (3NF). When the model has reached 3NF, you will construct the Entity Relationship Diagram (ERD) depicting the logical
  • 12. design of the database. Your ERD will use Crow‘s Foot notation to denote the relationships between tables. Sample Exercise, With Solution Before completing your lab, please review this example problem. The diagram below is a partial depiction of a business spreadsheet for a retail store operation. The store sells books. Books have a 13-digit International Standard Book Number (ISBN), a title, a publisher, and a unit price. Invoices track sales of books. An Invoice contains one or many line items, with each line item reflecting the sale of one or more copies of a specific book. Every publisher has a company name, and a publisher code. InvNum ISBN13 InvDateBookTitlePubCodePubNameQtyunitPrice 1022 9781291940336 2015-03-09 MYSQL Functions 1001 Lulu.com 3 4.99 1022 9780321833877 2015-03-09 MySQL, Fifth Edition 1029 Addison- Wesley 5 33.95 1022 9781890774820 2015-03-09 Murach‘s MySQL, 2nd Edition 1032 Murach, Mike & Associates, Inc 2 48.95 1249 9781449374020 2015-02-22 MySQL Cookbook: Solutions for Database Developers and Administrators 1118 O‘Reilly Media, Incorporated 9 50.59 1249 9781449325572 2015-02-22 PHP & MySQL: The Missing Manual 1118 O‘Reilly Media, Incorporated 6 29.95 1249 9781890774790 2015-02-22 Murach‘s PHP and MySQL, 2nd Edition 1032 Murach, Mike & Associates, Inc 1 48.95 BookSales
  • 13. 1. Using the BookSales table structure shown above, draw the dependency diagram, and show all dependencies, full, partial, and transitive. Figure 1 -solution 1 Discussion: A composite primary key consisting of InvNum + ISBN13 can be constructed, ensuring that all rows are unique. All remaining attributes are shown to be dependent (at least partially) on this composite key, so the table is 1NF. Further analysis shows that InvDate is dependent on only part of the key (InvNum), and that unitPrice, PubCode, and BookTitle also depend on part of the key (ISBN13). A transitive relationship is also revealed: PubName truly depends on PubCode, which in turn depends on ISBN13. 2. Using the answer to exercise 1, remove all partial dependencies and draw the new dependency diagrams. For each new table created, specify its normal form (1NF, 2NF, 3NF). Figure 2- solution 2 Discussion: To achieve 2NF, we must remove partial dependencies. This is done by decomposing into three tables, and three dependency diagrams at this stage. Notice that the Transitive relationship has not yet been addressed. 3. Using the answer to exercise 3, remove all transitive dependencies, and draw the new dependency diagrams. For each new or revised table, specify its normal form. Figure 3 – Solution 3
  • 14. Discussion: The transitive relationship has been removed by creating the Publishers table, in which PubName is fully dependent upon PubCode. Pubcode also persists as a dependent attribute and Foreign Key in Books. All tables are now in 3NF, and have been given meaningful names reflecting the entities they represent. LINEITEMS represents the collection of line items for all invoices. Invoices represents the collection of Invoices for all customer orders. Books makes up the list of all books available for sale (whether they have ever been ordered or not). Each book has a publisher, and the publisher code and Name reside in the Publishers table. 4. Draw the ERD for exercise 3, using Crow‘s Foot notation. End of Sample Exercise. Student Exercise The student exercise for this lab is similar to the sample exercise presented above. Consider the following spreadsheet containing information about customers, their shipping and billing addresses, and the countries corresponding to each of those addresses. A customer may be associated with zero to many addresses. A customer may have 0 or 1 default billing address. A customer may have 0 or 1 default shipping address. Each address may be associated with 0 or 1 countries, while each country may be associated with 0 to many addresses. cust_idfnamelnamedef_bill_addr_iddef_ship_addr_idaddr_idstreet_addr city state zip country_codecountry_name
  • 15. 202 John Smith 1096 2039 1096 123 Happy Ave. Orlando FL 32801 76 United States 202 John Smith 1096 2039 2039 2024 Shorline Dr. Seattle WA 98101 76 United States 202 John Smith 1096 2039 8053 100 N. Kent Ave. St. James WA 34 Jamaica 175 Hilda Yeager 2172 2172 3879 48 Spatzel Ct. Dusseldorf 5111 29 Germany 175 Hilda Yeager 2172 2172 3921 162 Rue Moritz Paris 75001 28 France 321 Siri Apple 1881 1881 1881 1 Infinite Loop Cupertino CA 95014 76 United States Using the example solution as a guide, perform the following steps. 1. Using the CustomerAddressCountry spreadsheet show above, draw the dependency diagram, and show all dependencies, full, partial, and transitive. Paste your solution into the answer sheet, and label it, Answer #1. 2. Using the answer to exercise 1, remove all partial dependencies and draw the new dependency diagrams. For each new table created, specify its normal form (1NF, 2NF, 3NF). Paste your solution into the answer sheet, and label it, Answer #2. 3. Using the answer to exercise 3, remove all transitive dependencies, and draw the new dependency diagrams. For each new or revised table, specify its normal form. Paste your solution into the answer sheet, and label it, Answer #3.
  • 16. 4. Draw the ERD for exercise 3, using Crow‘s Foot notation. Paste your solution into the answer sheet, and label it, Answer #4. ============================================== CIS 336 iLab 2 The Expanded Entity Relationship Diagram FOR MORE CLASSES VISIT www.cis336study.com CIS336 Lab 2: The Expanded Entity Relationship Diagram LAB OVERVIEW Scenario and Summary This lab introduces the next step in creating a data model, the Entity Relationship Diagram (ERD). You will be given a business scenario for a University Medical Center, which is a small community hospital. The business specifications will outline a number of things about the business, some of which will apply directly to the database you are being asked to model. There is a table that lists the entities (tables) that will be needed for the database and related attributes (columns) for each entity. There is also a column that lists specific information about the entity that will be helpful in determining its relationship to other entities within the model.
  • 17. Be sure to include the minimum and maximum occurrences of each relationship (cardinality) and to supply a name to the relationship that will work in both directions. Make sure to use Crow‘s Feet notation in your ERD. Narrative/Case Study The University Medical Center is a small, community hospital. A new hospital administrator has recently been hired by the Board of Directors, and directed to right-size patient care and pharmacy services and improve profitability. The hospital operates three clinical facilities: the main hospital, a mid-town clinic, and an Urgent Care location. The hospital also offers selected in-home care services. Many of the patients are repeat or regular patients who receive regular treatment for various conditions, and many utilize the hospital‘s pharmacy services for prescription medications. The pharmacy dispenses about 3,000 different prescription medications of various kinds. Every prescription is associated with one patient, and is logged by the dispensing clinic. The new administrator wants to know which drugs are most prescribed, and also which are the most profitable. The following is some general information about the organization and its current processes. • The hospital operates three clinical facilities. • A healthcare worker logs in at a facility at the start of a shift and logs out at the end. • The name, address, Social Security number and other information is recorded for every healthcare worker.
  • 18. • All healthcare workers have one billing rate, which is determined by their job description. • Each medication dispensed by prescription is linked to both the prescription number and the medication ID number, recording the item price and the quantity dispensed. As a convenient and affordable means of providing hospice care, palliative care, and convalescent care to patients that need occasional/intermittent skilled nursing, but do not require hospitalization, the hospital offers limited in-home care. Recording of in-home care includes the healthcare worker ID, their departure time and return time, and also the prescription ID for any prescriptions administered by the healthcare worker in the home setting. The hospital administrator would like to know what home-care visits have been made to whom, by whom, when, and how long they took. There is concern at this point that the cost of providing limited home healthcare is not providing adequate return on investment, and the program should be revised or discontinued. Requirements You have been asked to develop a logical data model for University Medical Center based on the information given to you by the new hospital administrator and their staff. Through analysis of the nouns and verbs in the case study above, you have accumulated the following entity, attribute, and relationship information shown in the table below. The attribute list may not be complete. If you determine that additional attributes are needed to better define an entity, then you should add them.
  • 19. Entities Attributes and Relationships for University Medical Center (Parallel Lab Exercise): Entity Attributes Relationships HealthcareWorkerHealthcareWorkerID, LastName, FirstName, SSN, Address, City, State, Zip, Phone Number, HealthcareWorkerTypeID A healthcare worker can belong to any one of the three job categories, but can belong to one and only one of the three. healthcare worker has names and other contact information. HealthcareWorkerTypeHealthcareWorkerTypeID, HealthcareWorkerTypeDesc, HourlyBillingRate A healthcare worker can be either a physician (diagnoses, prescribes medication), nurse (provides physician-ordered treatments, administers medications), or a pharmacist (dispenses, delivers medication). ClinicLogClinicLogID, ClinicID, Login, Logout, HealthcareWorkerID Patients may be treated by a healthcare worker at a clinic and can be tracked by the clinic log number. A healthcare worker must sign into the clinic before he or she can serve patients, and must sign out when finished treating patients at that clinic. A healthcare worker may serve portions of a shift at more than one clinic. Clinic ClinicID, ClinicLocationDesc, AMAAccredNum The hospital operates three clinical facilities: General Hospital, Midtown Clinic, and Urgent Care. InHomeCareInHomeCareID, HealthcareWorkerID, PrescriptionID, DepartTime, ReturnTime. Relates to both the healthcare worker and the prescription entities. This entity will help track provision of home healthcare. A healthcare worker can provide many home visits but a
  • 20. prescription is administered on a home visit by one and only one healthcare worker. Method MethodID, Method Description Relates to medication and identifies the method of administration, for example, oral, injection, and so on. Medication MedicationID, MedicationName, Dosage, Cost, QuantityOnHand, LastPurchasedDate, ReorderMinimum Identifies the medication the hospital pharmacy dispenses. One or more medications can be dispensed per prescription. The quantity on hand allows Pharmacists to determine the inventory levels. The reorder minimum can be used to determine when the inventory level has reached a reorder point. Prescription PrescriptionID, MedicationID, BillingAmount, TransactionDateTime, ClinicLogID, PatientID A prescription is identified by a single prescription order. Prescriptions are • made to one or more patients but only one patient at a time; • made by one or more pharmacists but only one pharmacist per prescription; • recorded on one or more clinics but only one clinic per prescription; and • administered by one or more nurses but no one prescription can be administered by more than one nurse. PrescribedMedicationPrescriptionID, MedicationID, ItemPrice, QuantityDispensed Prescribed medication is part of a prescription and records medication dispensed per prescription. Prescribed medication
  • 21. must be able to associate multiple medications sold on a single prescription number. Patient Patient Number, First Name, Last Name, Address, City, State, Zip, Phone Number A patient can be associated with multiple prescriptions, but any one prescription is to one and only one patient. A prescription can occur without a patient registering in the system (e.g., an unconscious patent arrives by ambulance in the emergency room and receives life-saving emergency treatment). Using an appropriate drawing/data modelling tool, develop an ERD that meets the following guidelines. • Draw the entities with their attributes. • Indicate the relationships between the entities using Crow‘s Foot notation. You will need to determine the cardinality and optionality for each direction of the relationships. Some of the Foreign Key relationships are identified in the graph above but not all. Be sure you identify and account for all Foreign Key relationships. • Add a name (in both directions) to the relationships. Remember, if you can verbalize the relationship in both directions, then you probably have a valid relationship. Deliverables The deliverable for this lab will be your completed ERD as a single MS Word document using copy/paste or imported as an image from your drawing/modelling application, cropped and sized appropriately (it should fit on a single page), and named lab2_solutions_yourname. LAB STEPS STEP 1: Drawing Entities and Attributes
  • 22. Back to Top Be sure to include all of the entities that have been defined. You need to include at least the primary and foreign key attributes where applicable in your diagram. STEP 2: Add Relationships Back to Top Be sure that you link all entities based on PK to FK relationships. There may be a case where you need to identify a combination PK and if so make sure that all of the relationships involved are defined. Be sure that you have set your drawing/modelling tool set to show Crow‘s Foot notation. Also, be sure that you are defining the correct cardinality for the relationships. STEP 3: Naming of relationships Back to Top If your drawing/modelling tool creates a default name for relationships, do not simply accept this default without due consideration. There may be some relationships where the default is applicable, but in most cases you will want to explicitly name the relationship. Be sure that you have provided a verb phrase for both directions in the relationship. This is the end of lab #2#4. ============================================== CIS 336 iLab 3 Building the Physical
  • 23. FOR MORE CLASSES VISIT www.cis336study.com CIS-336: Lab 3: Building the Physical LAB OVERVIEW Scenario and Summary The lab for this week addresses taking a logical database design (data model) and transforming it into a physical model (tables, constraints, and relationships). As part of the lab, you will need to download the zip file titled CIS336Lab3Files from Doc Sharing. This zip file contains the ERD, Data Dictionary, and test data for the tables you create as you complete this exercise. Your job will be to use the ERD Diagram found below as a guide to define the table structures and constraints using both CREATE TABLE and ALTER TABLE statements. Once this has been done, you will need to write the INSERT INTO TABLE statements to insert the data provided into the table. The data should verify that the constraints you have created are valid and define the correct referential and data
  • 24. integrity constraints asked for. Lastly, you will write SELECT statements to query the tables and verify the data was populated. Please use exactly the data provided, without addition, deletion, or alteration except as directed, as your results may be evaluated against expected results generated using this exact data set. Narrative/Case Study For this lab, you will be creating SQL statements to build a series of relational tables, using SQL CREATE statements in a script file format for the Student Database. You will then populate those tables through the use of INSERT statements with sample data. You will need to create a script file and name it YourName_Lab3.txt containing the following code. 1. The drop table statements listed later in the specifications of this lab. 2. The CREATE TABLE statements required to build the six tables. 3. The INSERT statements necessary to insert all of the sample data. 4. Six 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 ERD Diagram which follows, and the exact data to be inserted into each table, which may be found via the Doc Sharing tab
  • 25. on the course website. The following guidelines are being provided to help assist you in creating your script file. · Use the names for the tables and columns as listed in the ERD. Do not change them as it will affect your grade. · Creating Constraints o Create all NOT NULL constraints as indicated in the ERD. o Create all PK constraints as indicated in the ERD. o Create all FK constraints as indicated in the ERD. · Create all of the tables and all of the constraints before populating any of the tables with data. · Because FK constraints will be in place when the insert statements are executed, you will need to consider carefully which tables must be created before others in order to ensure that FK constraints are not violated. · The COURSE table has a self-referencing FK constraint. Specifically, some courses have prerequisite courses. Consequently, the record for a course possessing a prerequisite course cannot be successfully inserted into the table unless the record for the prerequisite course has
  • 26. already been inserted. This may require you to reorder the insert statements to resolve FK violations when loading the table. You may reorder the data provided for this table, but do not alter it. · The data for one table intentionally contains a record containing an FK constraint that is not resolved by a record in the parent table. This orphaned record has been included as an exercise for you to find. Because this record has an unreconciled FK constraint, it cannot be successfully inserted. You will need to delete or comment out the insert statement for this one record in order to produce a script that runs without errors. · Aside from reordering the data for the COURSE table as necessary, and commenting out/deleting the ONE record whose FK dependency cannot be resolved by the data provided, you are NOT to modify, add to, or delete from the data provided. Your SQL script must produce tables containing data identical to the expected solution set, or points will be deducted. · ALL character strings must be enclosed in single quotes. This includes alpha strings and
  • 27. alphanumeric (remember that any formatting within a numeric string makes it alphanumeric). · If you are inserting a NULL, do not enclose the word NULL in single quotes, as this will insert the word NULL into the row. To insert a null you simply use the word NULL. Deliverables The deliverable for this lab will include the following documents. 1. Your script file. Create this file in Notepad, or another PURE TEXT editor—NOT Word. Make sure your name is in a comment area at the top of the script file. Use a double dash to create a one- line comment. –Jane Smith –Lab 3 2. Your script file must execute without error. It is recommended that you begin early in the week, and post any questions to the Q & A discussion in order to produce a working script by the due date. Be sure your name is on all documents and that all documents have been included in a single zip file for this week‘s assignments.
  • 28. Refer to the following ERD in constructing your solution. Student PKStudent_ID Salutation First_Name Last_Name Street_Address Phone Employer Registration_Date FK1Zip Enrollment PK,FK1Section_ID PK,FK2Student_ID Enroll_Date Final_Grade LAB STEPS STEP 1: The DROP Statements A DROP TABLE statement must appear in your script file, prior to the SQL statements for creating
  • 29. the table in question. This will allow you to run and re-run your script file as often as you need to. The very first time you run your script the table does not exist, so the IF EXISTS clause causes the statement to be ignored. Thereafter, the table will be deleted, ensuring that your CREATE TABLE statement creates the table fresh and clean, with only the attributes present in the current revision of the CREATE statement. Here is an example of one of the six DROP TABLE statements you will need to create. DROP TABLE IF EXISTS `ENROLLMENT` ; STEP 2: The CREATE TABLE Statements Next, define the CREATE TABLE statements for the six tables that you are to create based upon the ERD (provided above) for this lab. Be sure to follow the guidelines given above on how and where to create the different types of constraints for each table. This will include PK, FK, and NOT NULL constraints. STEP 3: The INSERT Statements for the Data The third step is to create the insert statements to insert the sample data into the tables created in Step 2. The data for each table is contained in text files, named for the table whose data it contains.
  • 30. Modify the format of the data (e.g., date formats and add or eliminate quote marks) as needed to craft your insert statements, but do not change the inherent value of the data. STEP 4: The SELECT Statements The next step of the lab will be to create the select statements to verify the data was inserted correctly. You should have six 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 would be SELECT * FROM student; Be sure to save all of the above statements in your script file. STEP 5: Testing and Verifying Your Script Now we come to the point of verifying that your script file works by creating all of the tables and inserting and selecting all of the data. Your script should execute without errors, and select the entire contents of each table in turn. Inspect your query results to ensure that each column and row from each of the tables is as expected. Correct and repeat testing of your script until no errors occur, and the results match expectations. You may also use the DESCRIBE command to display the table structure of
  • 31. each table, and verify that PK and NULL constraints have been properly created. The SHOW CREATE TABLE statement is useful for displaying the SQL that would regenerate a given table, which is a useful way for checking that FKs have been properly created. Examples: DESCRIBE STUDENT; SHOW CREATE TABLE STUDENT; This is the end of Lab 3_____ ============================================== CIS 336 iLab 4 Introduction to Select, Insert, Update, and Delete Statements (only SQL Command, No output) FOR MORE CLASSES VISIT www.cis336study.com CIS336: Lab 4: Introduction to Select, Insert, Update, and Delete Statements LAB OVERVIEW
  • 32. Lab 4 will introduce the various aspects of the SQL select statement and the methods of retrieving data from the database tables. This lab will also introduce the fundamentals of updating and deleting records. This lab may be completed using either DeVry‘sOmnymbus EDUPE-APP lab environment, or a local copy of the MySQL database running on your own computer using the OM database tables. The lab will utilize a set of tables that are represented by the ERD (OM_ERD.docx) and are created and populated by the script file (create_OM_db.sql). Follow the instructions in the file CreateOMTables.docx to create your database, tables, and data. A few IMPORTANT things to note if using EDUPE MySQL: **There can be NO SPACES in alias names given to a column. For example: Select unit_price as ―Retail Price ― from items; –this does NOT work in EDUPE MySQL. Any of the following WILL WORK: Select unit_price as ―RetailPrice‖ from items; Select unit_price as ―Retail_Price‖ from items; Select unit_price as Retail_Price from items; Select unit_price as RetailPrice from items; **Any calculated fields MUST be given an alias (and note above NO SPACES in alias). For example: select unit_price * 2 from items; –this does NOT work in EDUPE MySQL This will work:
  • 33. select unit_price * 2 as NewPrice from items; Deliverables • Lab Report (Answer Sheet) containing both the student-created SQL command(s) for each exercise, and the output showing the results obtained. Be sure your name is on the file. LAB STEPS: Complete each of the exercises below. 1. Write a query that displays a list of all customers showing the customer first name, last name, and phone number. Sort the results by customer last name, then first name. 2. Write a query that displays each customer name as a single field in the format ―firstnamelastname‖ with a heading of Customer, along with their phone number with a heading of Phone. Use the IN operator to only display customers in New York, New Jersey, or Washington D.C. Sort the results by phone number. 3. Write a query that will list all the cities that have customers with a heading of Cities. Only list each city once (no duplicates) and sort in descending alphabetical order. 4. Write a query that displays the title of each item along with the price (with a heading of Original) and a calculated field reflecting the price with a 25% discount (with a heading of Sale). Display the sale price with two decimal places using the ROUND function. Sort by price from lowest to highest. 5. Write a query that displays the customer_first_name, customer_last_name, and customer_city from the customers table. Use the LIKE operator to only display customers that reside in any zipcode beginning with 4.
  • 34. 6. Write a query that displays the order id and order date for any orders placed from March 1, 2014 through April 30, 2014. Do this WITHOUT using the BETWEEN clause. Format the date field as Month dd, yyyy and use a heading of ―Ordered‖. 7. Write a query that displays the order id and order date for any orders placed during the month of May, 2014. Do this using the BETWEEN clause. Format the date field as mm/dd/yy and use a heading of ―Ordered‖. 8. Write a query which displays the order id, customer id, and the number of days between the order date and the ship date (use the DATEDIFF function). Name this column ―Days‖ and sort by highest to lowest number of days. Only display orders where this result is 15 days or more. 9. Write a query which displays the order id, customer id and order date for all orders that have NOT been shipped, sorted by order date with the most recent order at the top. 10. The Marketing Department has requested a new report of shipped orders for which the order was placed on either a Saturday or a Sunday. Write a query which displays the order id, order date, shipped date, along with a calculated column labeled ―Order_Day‖ showing the day of the week the order was placed (use the DAYNAME function). Only display orders that have shipped and were placed on a Saturday or Sunday. Sort by order date with most recent orders at the top. 11. Write a query to display the customer last name, phone number, and fax number but only display those customers that have a fax number. 12. Create a statement to insert a new record into the items table with the following values:
  • 35. item_id: 11 title: Ode To My ERD Artist_id: 15 unit_price: 12.95 Show your INSERT statement along with the results of the following SELECT query to verify that the insert worked correctly. select * from items where item_id> 10; 13. Create a statement to update the record inserted in the previous step to change the unit price of this item to 7.95. item_id: 11 title: Ode To My ERD artist: 15 unit_price: 7.95 Show your UPDATE statement along with the results of the following SELECT query to verify that the insert worked correctly. select * from items where item_id> 10; 14. Create a statement to delete the entire record that was inserted and then updated in the previous steps. Show your DELETE statement along with the results of the following SELECT query to verify that the insert worked correctly. select * from items where item_id> 10; 15. Using the SUBSTRING and CONCAT functions, write a query to display each customer name as a single field in the format ―Jones, Tom‖
  • 36. with a heading of Customer along with the customer_phone field in a nicely formatted calculated column named Phone. For example, a record containing the customer_phone value 6145535443 would be output with parentheses, spaces, and hyphens, like this: (614) 555-5443. Sort by last name. This is the end of Lab 4. ============================================== CIS 336 iLab 5 Joining Tables FOR MORE CLASSES VISIT www.cis336study.com CIS336: Lab5: Joining Tables LAB OVERVIEW Scenario and Summary Lab 5 will introduce the concept of multi-table JOINS in order to work with data in two or more related tables simultaneously. This lab may be completed using either DeVry‘sOmnymbus EDUPE-APP lab environment, or a local copy of the MySQL database running on your own computer using the OM database tables. The lab will utilize a set of tables that are represented by the ERD (OM_ERD.docx) and are created and populated by the script file (create_OM_db.sql). Follow the
  • 37. instructions in the file CreateOMTables.docx to create your database, tables, and data. A few IMPORTANT things to note if using EDUPE MySQL: **There can be NO SPACES in alias names given to a column. For example: Select unit_price as ―Retail Price ― from items; –this does NOT work in EDUPE MySQL. Any of the following WILL WORK: Select unit_price as ―RetailPrice‖ from items; Select unit_price as ―Retail_Price‖ from items; Select unit_price as Retail_Price from items; Select unit_price as RetailPrice from items; **Any calculated fields MUST be given an alias (and note above NO SPACES in alias). For example: select unit_price * 2 from items; –this does NOT work in EDUPE MySQL This will work: select unit_price * 2 as NewPrice from items; Deliverables • Lab Report (Answer Sheet) containing both the student-created SQL command(s) for each exercise, and the output showing the results obtained. Be sure your name is on the file. LAB STEPS: Complete each of the exercises below:
  • 38. 1. Use the JOIN ON syntax to write a query to display the order id, order date, customer name formatted as a single field (i.e. ―Tom Jones‖) with a heading of Customer, and customer_city for customers residing in the state of OHIO. Sort the output to display the newest orders first. 2. Use the JOIN USING syntax to display the order_id, order date, and shipdate for orders to Karina Lacy that have shipped. 3. Use the implicit join syntax (the WHERE clause) to display the last name, city, order date and ship date for all orders shipped in 2012. 4. Use any join syntax EXCEPT NATURAL JOIN to list the customer_first_name and customer_last_name concatenated with an intervening space as Customer, customer city and state formatted as a single column in the format of ―city, ST‖ with a heading of Location, order_id and order date for orders that have not shipped. 5. List the customer name, order date, zipcode for any customer(s) placing an order for the item titled ‗Etcetera‖. 6. Write a query to list the title and artist of ONLY the items that have been ordered. Only list each title once. 7. Write a query to list the title and price of all items that have been ordered by customer Millerton. 8. Write a query to list the last name and order id of customers that ordered any items by the artist Burt Ruggles? 9. Write a query to display a list of titles along with the artist name., sorted by artist name. 10. Write a query to display an invoice for order 693 including the title, quanty, price, and a calculated column to display the line item subtotal (quantity times price) with a heading of Subtotal.
  • 39. 11. Display the order id, last name, title , and quantity for any items where customers have ordered 2 or more of a particular item in an order. 12. The employees table contains a list of employees of a company. An employee may be managed by another employee. To denote an employee‘s manager, the employee_id of the manager is entered into the manager_id field of the employee reporting to that manager. In order to produce a list of which managers supervise which employees, the table may be joined to itself using these two attributes (employee_id, manager_id). This is known as a SELF-JOIN. Use a SELF-JOIN on the employees table to produce a result containing two columns: the concatenated last_name and first_name of the manager, and the concatenated last_name and first_name of the employee. Label the first- column supervisor, and the second-column employee. Order the output by the supervisor‘s last_name and first_name. 13. Write a query to display the order id, order date, ship date, and customer last name for all SHIPPED orders placed on the internet (no employee id). Show the most recently shipped orders first. 14. Write a query that displays the order id, order date, and employee name as a single field labeled Employee for each order that an employee assisted with. 15. Write a query that displays the order id, order date, customer name as a single field labeled Customer for all orders for the sales rep Thomas Hardy, sorted by customer last name. This is the end of Lab 5. ==============================================
  • 40. CIS 336 iLab7 Working with Views FOR MORE CLASSES VISIT www.cis336study.com CIS-336: Lab7: Working with Views LAB OVERVIEW Lab 7 will introduce the concept of database views. This lab may be completed using either DeVry‘sOmnymbus EDUPE- APP lab environment, or a local copy of the MySQL database running on your own computer using the OM database tables. The lab will utilize a set of tables that are represented by the ERD (OM_ERD.docx) and are created and populated by the script file (create_OM_db.sql). Follow the instructions in the file CreateOMTables.docx to create your database, tables, and data. A few IMPORTANT things to note if using EDUPE MySQL: **There can be NO SPACES in alias names given to a column. For example: Select unit_price as ―Retail Price ― from items; –this does NOT work in EDUPE MySQL.
  • 41. Any of the following WILL WORK: Select unit_price as ―RetailPrice‖ from items; Select unit_price as ―Retail_Price‖ from items; Select unit_price as Retail_Price from items; Select unit_price as RetailPrice from items; **Any calculated fields MUST be given an alias (and note above NO SPACES in alias). For example: select unit_price * 2 from items; –this does NOT work in EDUPE MySQL This will work: select unit_price * 2 as NewPrice from items; Deliverables • Lab Report (Answer Sheet) containing both the student-created SQL command(s) for each exercise, and the output showing the results obtained. Be sure your name is on the file. LAB STEPS: Complete each of the exercises below. 1. Use an ALTER TABLE statement to update the customers table so that the Primary Key field is an auto-increment field, then create TWO insert statements to test proper operation, using your own first and last name for one (and a name of your choice for the second one), and any data you care to imagine for the remaining fields.
  • 42. IMPORTANT NOTE: When using a LOCAL copy of MySQL, if you attempt to simply issue the ALTER TABLE command you have composed by itself, you should receive an error similar to the following (try it for yourself!). ERROR 1833: Cannot change column ‗customer_id‘: used in a foreign key constraint ‗orders_fk_customers‘ of table ‗om.orders‘ (Note – EDUPE will not give this error message, however you should still follow the CORRECT procedure as discussed here to complete this problem). The reason for this is that you are attempting to alter data in one column that has a defined PK:FK relationship to a field in another table. Referential Integrity rules prevent this. So, how do you resolve such a problem? One approach to solving this dilemma is to turn off the foreign key checks that implement referential integrity rules. However, the danger here is that other users and processes operating on the database while these constraints are suspended could create or modify data in a way that compromises integrity. We can solve this second problem by preventing other users and processes from altering the data in the table in which we are working until we have turned the foreign key checks back on. We therefore need to construct a script that does the following. a) Locks the customer table – lock table customers write;
  • 43. b) Turns off FK checks – set foreign_key_checks = 0; c) Alters the table to add the auto_increment feature to the PK field d) Turns FK checks back on – set foreign_key_checks = 1; e) Unlocks the customer table – unlock tables; It is VERY important to consider that altering tables can require a bit of time for very large tables, and that while the table is locked, other users and processes cannot operate. Consequently, this kind of modification should not be done during peak operating hours in a production operation (as a student in a lab exercise, working on your own database, you may do this at any time) but ideally in hours during which the business does not normally operate. In cases where round-the-clock, high availability of a database is required, other approaches may be required. Addressing this problem in a high-availability, high- demand environment is an advanced topic, study of which is outside the scope of this course. Use the outline below to construct your script. Show all commands in your answer sheet along with the output of the commands. lock table customers write; set foreign_key_checks = 0; – Replace this comment with your ALTER TABLE command to add the auto_increment feature to the PK field
  • 44. set foreign_key_checks = 1; unlock tables; –statements to insert two rows into the table –verify auto_increment with a select statement 2. The Vice President of Marketing for your firm wants the firm‘s sales representatives to be able to directly view and edit customer details, but only for the state to which a particular sales representative is assigned. You have suggested that this need can be addressed with a view. For example, a view could be created for one particular state, and user account permissions for accessing that view granted only to sales representatives from that state. The VP has asked you to quickly create a simple proof-of-concept demonstrating how this might work. Complete the following steps: a. Construct a view on the customers table called CA_CUSTOMERS that consists of all data about customers that live in California. b. Display the data using this view to verify that only customers that reside in California are visible. c. Prove that It is possible to add or update records through this view by updating the record for Karina Lacy to change the spelling of Karina‘s last name to Lacie.
  • 45. d. Display the data using the customer table to verify that the change has been made. Show all commands in your answer sheet along with the output of the commands. 3. The Senior Customer Service Manager has requested the ability to create a report at any time that will show shipped orders that took some specified number of days to fulfill. a. Create a view named SHIPPING_TIME that lists only customer_first_name, customer_last_name, order_date, shipped_date, and the calculated field days_to_fulfill (use the DATEDIFF function) showing the number of days between when the customer placed the order and when it was shipped. Show the data from this view. Now let‘s do some queries by adding sorting and filters USING THIS VIEW, WITHOUT CHANGING IT. b. Use the view to display the data sorted by highest to lowest days to ship c. Use the view to display only the orders that took less than 10 days to ship. d. Use the view to display only the orders that took more than 30 days to ship.
  • 46. 4. Queries that require joins and aggregate functions can be easier to construct when using a view as a ―temporary‖ table. Consider a report to show total sales by artist. a. First create a view called SalesData that displays the order_id, item_id, the calculated field ItemTotal (which is quantity times price), the title and artist_id. b. Display the data in the SalesData view sorted by artist_id. Does this help you to ―visualize‖ how to group the data to create the totals? c. Create a query USING THIS VIEW and the appropriate aggregate function to display artist_id and the total sales for each artist. d. Now join to the artist table in order to display the artist_name along with the total sales. 5. Now use this same method to display the total sales per customer. a. Create a view called SalesData with the appropriate data. At a minimum you will need customer_id and the calculated item total. DO NOT use the customer table in this view, it will be joined later. b. Display the data in your view sorted by customer_id. Does this help you to ―visualize‖ how to group the data to create the totals?
  • 47. c. Create a query USING THIS VIEW and the appropriate aggregate function to display customer_id and the total sales for each customer. d. Now join to the customer table in order to display the customer_name as a single field named Customer along with the total sales. Sort the report by Total sales in descending order. This is the end of Lab 7. ============================================== CIS 336 Quiz 1 (Devry) FOR MORE CLASSES VISIT www.cis336study.com (TCO 3) Normalization works through a series of stages called normal forms. Typically _________ stages must be completed before a table can be considered normalized. (TCO 3) The conflicts between design efficiency, information requirements, and processing speed are often resolved through
  • 48. (TCO 3) The PK must uniquely identify each entity instance. A primary key must be able to guarantee unique values. It cannot contain nulls. This rationale belongs to (TCO 9) The SQL command that lets you insert data into a table, one row at a time, is _____________. (TCO 4) Which command is used to restore the table's contents to their default values? (TCO 4) Which of the following SQL commands would alter the table DEVRY and add a foreign key that references the CITY table? (TCO 4) The SQL command that lets you save your work to disk, is ___________ (TCO 9) If the INSERT INTO command is used to insert data values that violate an existing constraint in a table, which of the following will happen? (TCO 3) Explain under what circumstances a partial dependency can exist in a database. ============================================== CIS 336 Quiz 2 (Devry)
  • 49. FOR MORE CLASSES VISIT www.cis336study.com (TCO 2) Explain what a composite attribute is (TCO 1) Data constitutes the building blocks of (TCO 1) Successful database design is first and foremost based on _____________ requirements. (TCO 1) The lowest level in a database hierarchy is the ____________ or value as it is often referred (TCO 2) The term _____________ design is used to refer to the task of creating the conceptual data model represented by an Entity Relationship Diagram (ERD). (TCO 2) Within a table, the primary key must be unique so that it will identify each row. When this is the case, the table is said to exhibit ___________.
  • 50. (TCO 2) A field that consists of data values that can be used for arithmetic procedures is a _________ type field. (TCO 2) A relationship is an association between ___________ (TCO 5) The _____________ model represents a global view of the data. (TCO 5) In Crow's Foot notation, a forked end means ============================================== CIS 336 Quiz 3 (Devry) FOR MORE CLASSES VISIT www.cis336study.com (TCO 7) Which of the following types of columns will automatically right-align the data when it is displayed?
  • 51. (TCO 7) Which of the following SQL statements will display the profit generated by each book currently stored in the BOOKS table? (You do not need to see the table structure for this question) (TCO 7) Which of the following will display the new retail price of each book as 20 percent more than it originally cost? (TCO 7) Which of the following operators would be most appropriate to determine whether or not the retail price of a book is at least $24.00? (TCO 7) The ______________________ comparison operator is used to indicate that a data value must fall within a range of values to be included in the query results. (TCO 7) Based upon the contents of the BOOK_ORDER table shown below, which of the following queries will display all orders that were not shipped for at least three days after the order was received? (TCO 7) ANSI-standard SQL allows the use of a special operator in conjunction with WHERE clause. A special operator used to check whether an attribute matches one from a subquery is_______. (TCO 7) A ____ occurs when a relationship is improperly or incompletely identified and, therefore, is represented in a way that is not consistent with the real world.
  • 52. (TCO 7) The ______________________ comparison operator is used to search for values which are not NULL. TCO 7) You want to write a query that will return the customer number, first and last name from the book_order table (shown below) for all customers who have a P.O. Box and who live in either Trenton or Chicago. Write the query that will accomplish this task. ============================================== CIS 336 Quiz 4 (Devry) FOR MORE CLASSES VISIT www.cis336study.com (TCO 8) If a Cartesian join is used to link table A which contains five rows to table B which contains eight rows, there will be _______ rows in the results. (TCO 8) Which of the following statements will produce the value 21.1? (TCO 8) Which of the following format elements will display insignificant leading zeros?
  • 53. (TCO 8) Oracle‘s pseudo table used only for cases where a table is not really needed is _________? (TCO 7) Using the BOOK_CUSTOMER and BOOK_ORDER tables shown below for reference which SQL statement will return the same results as the following SQL statement? (TCO 7) A table alias or qualifier cannot be assigned in the FROM clause of which type of join? (TCO 7) The _______ query joins a table to itself using aliases to distinctly identify each instance of the table. (TCO 7) Explain the difference between an inner join and an outer join. ============================================== CIS 336 Quiz 5 (Devry) FOR MORE CLASSES VISIT www.cis336study.com (TCO 6) Which of the following keywords is used to remove a row in a table?
  • 54. (TCO 6) When using the ALTER TABLE...DROP COLUMN command, which of the following is NOT correct? (TCO 6) Which of the following commands will add a new column named FIRSTORDERDATE to the CUSTOMERS table to store the date that the customer first placed an order with the company? (TCO 8) Which of the following is NOT a valid statement? (TCO 8) Based on the contents of the BOOKS table shown below, which of the following SQL statements will return the total profit generated by books in the COOKING category? (TCO 8) Which comparison operator evaluates a subquery and if it returns false, will not execute the calling query? (TCO 8) The following SQL statement contains which type of subquery? (TCO 9) If the _________ clause of the UPDATE command is omitted, then all the rows in the specified table will be changed. (TCO 9) Which of the following is not a valid SQL command? (TCO 9) Based on the contents of the PROMOTION table, which of the following commands will delete only the row for the Free Bookmark from the table?
  • 55. (TCO 8) In using group functions we cannot place a group function in a WHERE clause. Explain how the WHERE clause and HAVING clause similar and why you can use the HAVING with a group function but not a WHERE clause. ============================================== CIS 336 Week 2 Quiz (New) FOR MORE CLASSES VISIT www.cis336study.com Question 1. (TCO 1) Raw facts, such as a telephone number, a birth date, and a customer name, are also referred to as _____ Question 2. (TCO 1) The DBMS allows you to extrapolate information from your data by using a _____ Question 3. (TCO 1) A database row (record) consists of _____ Question 4. (TCO 2) In Oracle, a _____ is automatically constrained to be unique and not null. Question 5. (TCO 2) A verb associating two nouns in a business rule usually translates to a(n) ___ in the data model.
  • 56. Question 6. (TCO 2) In a relationship, when a primary key from one table is also defined in a second table, the field is referred to as a _____ in the second table. Question 7. (TCO 2) In a relational database, each table must have _____ Question 8. (TCO 5) The product of a logical model is the entity relationship diagram, also known as a _____ ============================================== CIS 336 Week 3 Quiz (New) FOR MORE CLASSES VISIT www.cis336study.com Question 1. (TCO 3) When designing a database, you should _____ Question 2. (TCO 3) A table that is in 1NF and includes no partial dependencies only is said to be in _____ Question 3. (TCO 3) (TCO 3) A table is not in 1NF if _______________. Question 4. (TCO 9) All of following are examples of DML commands except _____
  • 57. Question 5. (TCO 4) Which of the following is not considered a database object? Question 6. (TCO 4) In Oracle, the DEFAULT constraint is used to _____ Question 7. (TCO 4) The SQL command that lets you save your work to disk, is _____ Question 8. (TCO 9) Which of the following SQL statements would insert a line of data into the DEVRY table and supply a NULL value for the Student_city column? ============================================== CIS 336 Week 4 Quiz (New) FOR MORE CLASSES VISIT www.cis336study.com Question 1. (TCO 7) Which of the following types of columns will automatically right-align the data when it is displayed? Question 2. (TCO 7) Which of the following symbols can be used to denote that any and all characters following the sign are eligible when used with LIKE? Question 3. (TCO 7) Based upon the contents of the BOOKS table shown below, which of the following is a valid SQL statement?
  • 58. Question 4. (TCO 7) Which of the following operators would be most appropriate to determine whether or not the retail price of a book is at least $24.00? Question 5. (TCO 7) Based upon the contents of the BOOK_ORDER table shown below, which of the following SQL statements will list all orders placed by customer# 1020 that have not yet been shipped? Question 6. (TCO 7) Based upon the contents of the BOOK_ORDER table shown below, which of the following queries will display all orders shipped between April 4, 2003 and April 5, 2003? Question 7. ((TCO 7) The ____ comparison operator is used to search for values that are not NULL. Question 8. (TCO 7) You want to write a SQL query that lists all employees in the EMP table whose last names in the EMP_LNAME column start with Smith, including values such as Smithfield. What is the correct statement? ============================================== CIS 336 Week 5 Quiz (New) FOR MORE CLASSES VISIT www.cis336study.com
  • 59. Question 1. (TCO 8) The ____ set operator in SQL combines rows from two queries and returns only the values that are common between the two sets. Question 2. (TCO 8) Which SQL function converts a value to a particular string format? Question 3. (TCO 8) Based upon the contents of the BOOK_ORDER table shown below, which of the following SQL statements will display only those orders shipped to the zip code zone that begins with 323? Question 4. (TCO 8) Oracle‘s pseudo table used only for cases where a table is not really needed is _____ Question 5. (TCO 7) Using the BOOK_CUSTOMER and BOOK_ORDER tables shown below for reference, which SQL statement will return the first and last name of each customer who's order has not yet shipped? Question 6. (TCO 7) A table alias or qualifier cannot be assigned in the FROM clause of which type of join? Question 7. (TCO 7) A(n) ____ join returns not only the rows matching the join condition (that is, rows with matching values in the common columns) but also the rows with unmatched values. Question 8. (TCO 7) Which statement will display the date in this format: ============================================== CIS 336 Week 6 Quiz (New)
  • 60. FOR MORE CLASSES VISIT www.cis336study.com Question 1. (TCO 6) Which of the following keywords can be used to change the size, datatype, or default value of an existing column? Question 2. (TCO 9) If the _____ clause of the UPDATE command is omitted, then all the rows in the specified table will be changed. Question 3. (TCO 6) Which of the following commands will increase the size of the CITY column in the CUSTOMERS table from 12 to 20 and increase size of the Question 4. (TCO 8) Based upon the contents of the BOOKS table shown below, which of the following SQL statements will return the number of different categories contained in the table? Question 5. (TCO 9) Which of the following is not a valid SQL command? Question 6. (TCO 8) Based on the contents of the BOOKS table shown below, which of the following SQL
  • 61. statements will return the total profit generated by books in the COOKING category? Question 7. (TCO 8) Before the COMMIT command is used, you can retrieve deleted records by using the _____ command. Question 8. (TCO 8)Based on the contents of the BOOK_ORDER table shown below, which of the following SQL statements will list the order number and customer number for the most recent orders in the system? Question 7. (TCO 8) Before the COMMIT command is used, you can retrieve deleted records by using the _____ command. Question 8. (TCO 8)Based on the contents of the BOOK_ORDER table shown below, which of the following SQL statements will list the order number and customer number for the most recent orders in the system? ============================================== CIS336 iLab 6 Group Functions and Subqueries FOR MORE CLASSES VISIT
  • 62. www.cis336study.com CIS336: Lab 6: Group Functions and Subqueries LAB OVERVIEW Scenario and Summary Lab 6 will introduce the concept of group functions and subqueries to meet more complex report requirements. This lab may be completed using either DeVry‘sOmnymbus EDUPE-APP lab environment, or a local copy of the MySQL database running on your own computer using the OM database tables. The lab will utilize a set of tables that are represented by the ERD (OM_ERD.docx) and are created and populated by the script file (create_OM_db.sql). Follow the instructions in the file CreateOMTables.docx to create your database, tables, and data. A few IMPORTANT things to note if using EDUPE MySQL: **There can be NO SPACES in alias names given to a column. For example: Select unit_price as ―Retail Price ― from items; –this does NOT work in EDUPE MySQL. Any of the following WILL WORK: Select unit_price as ―RetailPrice‖ from items; Select unit_price as ―Retail_Price‖ from items; Select unit_price as Retail_Price from items; Select unit_price as RetailPrice from items;
  • 63. **Any calculated fields MUST be given an alias (and note above NO SPACES in alias). For example: select unit_price * 2 from items; –this does NOT work in EDUPE MySQL This will work: select unit_price * 2 as NewPrice from items; Deliverables • Lab Report (Answer Sheet) containing both the student-created SQL command(s) for each exercise, and the output showing the results obtained. Be sure your name is on the file. LAB STEPS: Complete each of the exercises below. 1. Write a query to determine the total number of items on each order. Display the order_id and the total with a heading of TotalItems (note no spaces). Filter to only display information for order_id of 600 or higher. 2. Re-do query 1 but filter to only show those orders with more than 2 items ordered. Sort by the number of items ordered, lowest to highest. 3. The order_details table has a quantity for each item ordered. Show the total amount charged for each item on the order (quantity times price). Display order_id, the item id, the unit price, the quantity times price of the item labeled as ―Itemtotal‖ (note NO spaces). Sort by order id and filter to only display those order ids between 400 and 700. 4. Write a query to display the total amount for each order: show the order id and total. Sort by descending order on the total and only display orders with a total of $40 or more.
  • 64. 5. Re-do query 4 but show the customer name for each order (formatted as a single field with heading of Customer) along with the city, order id and total. Filter to only display customers that live in California. Sort by city. 6. Display the total amount of sales per item. Show title, total quantity sold with a heading of Quantity, total sales with a heading of ―TotalSales‖ (not NO space). Sort by highest to lowest total. 7. Display the total sales for each customer: show customer name (as single field) with a heading of Cutomer and total. Sort lowest to highest total. Filter to only display customers with $50 or more in total orders. 8. Use subqueries to determine which (artist) had the item ordered in highest quantity on an order? First determine the highest quantity on any order, then determine the item number associated with it, then display the artist. 9. Display the total sales by artist: show artist name, total. Sort highest to lowest. 10. USE A SUBQUERY to Increase price of all items by ‗No Rest for the Weary‘ by 10%. If working in MySQl you will need to disable safe mode. Show prices before and after. Rollback after. 11. USE A SUBQUERY to display names of customers that have unshipped orders. 12. Display the total amount of sales made to customers in NY 13. USE A SUBQUERY to list the items (title and artist) of items that have never been ordered 14. Show the order history for Samuel Jacobsen. Display the order id, order date, ship date, and total.
  • 65. 15. Show the total amount of sales per sales rep. Display the employee name as a single field along with the total sales, sorted by highest to lowest sales. This is the end of Lab 6. ==============================================