SQL Part 1 Assignment Instructions
SQL Part 1 Assignment Instructions
Statement
Purpose
This assignment reviews the main concepts of relational database and helps to practice on
writing simple SQL queries.
Requirements:
We will be working with the BSU_Students_3nd_edition database in MS Access.
Find the file and copy it onto your pc or a USB “flash” drive. You can now use the database with
any PC that has MS Access 2007 or later; which include the PC’s in the CoB computer
lab. Double click on the data base to open Access If an error message appears about a missing
link close the message box. [you may have to click on “enable content” when it opens].
Step 1: View the entity Relationship Diagram (ERD) for the tables in this database. Compare it to
the one shown on the next page to be sure you have the correct database. Paste it into a word
file, save the file and print it [landscape] be sure it is readable. You will need this for future
exercises.
1
1. (2 points) Looking at the ERD
a. What is the primary key of the BSU_Class table? ClassID
b. What is the primary key of the BSU_Major table? MajorID
c. What is the primary key of the BSU_StudentSchedule? ClassID, StudentID
d. What foreign key(s) are in the BSU_Students table? StudentID
2. (3 points) In Structured Query Language (SQL) the select statement is used to extract
data from a table or tables. The statement has six clauses. Complete the description
below:
a. Select (Which columns of Data to get, use* to select all columns)
b. From (Which Table has the data)
c. Where (Which rows of data to get)
d. Group by summarizes rows based upon membership in a group, e.g., dept.
e. Having used with “group by” clause to further filter results, e.g., < 10 employees
f. Order by (what column are used to sort the results)
2
3. (15 points) For the following questions, please copy and paste your queries. Run it in the
Access first to check if the query is written properly. Then copy and paste your results.
To create a query:
Select the “Create” tab, click “Query Design”. Close the pop-up box listing tables and
select “SQL view”.
a. (3 points) Write and run the SQL to list the different expected graduation
dates [class of 20XX] in the BSU_Students table. List each expected graduation
date only once.
i. Paste the SQL code here:
SELECT StuExpectedGradDate
FROM BSU_Students
Group by StuExpectedGradDate;
3
c. (4 points) Write a single SQL query using the BSU_StudentSchedule table that
will return a table, which shows students that have completed course
Acct23020. Sort the table by student id and semester.
i. Paste the SQL code here:
SELECT *
FROM BSU_StudentSchedule
WHERE course = 'Acct23020'
ORDER BY student_id, semester;
4
i. Paste the SQL code here:
SELECT COUNT(student_id)
FROM BSU_Students
WHERE last_name LIKE '%r' ;
Rubrics
For coding questions, resulting tables are required and each is worth of 1 point. Queries that do
not run will not earn any points. Queries that run but do not extract the information required
will earn 50% of points.
You may submit a Microsoft Word (.doc/.docx) document as an attachment using the
Assignment tool, or you may copy and paste your answer into the provided box within the
Assignment tool. If you attach a document for your assignment, be sure to include your name
in the text of the document and in the name of the document.
You can only submit once, so make sure you are completely finished before submitting
and that you attach the correct word .doc/.docx file.
Submissions sent by email will NOT be accepted in general, with instructor’s permission
only for unexpected contingencies.
Due dates are listed in the Assignment Schedule document.