Share
Explore BrainMass

SQL Joins and Typical Query Usage.

Create the following queries on the ITCO630_A database used in unit 3 and save them all in a file called ITCO630_P5.SQL. Please note that you can execute individual queries in a query file by highlighting the lines that you want to execute before running the script. Remember to define what database to use with a USE statement.

1. Using a join, get the full details of all the students who work on the mid-term exam assignment.
2. Get the assignment names (duplicates eliminated) being worked on by students at Central University.
3. Get the last names of all the students who are working on assignment A1.
4. Get the student numbers and start dates of all the students with start dates equal to the earliest date.
5. Insert yourself into the student table using the last five digits of your phone number as the student number and show yourself as attending Central University. Then show all the records in the student table.
6. Delete yourself from the student table by matching your student number, and then show all the records in the student table.

You should create a zip file called ITCO630_P5.ZIP with your query file (ITCO630_P5.SQL) included.

- Communicate with a relational database to create tables, and query and manipulate data.
- Use normalizing and data integrity methodologies when designing a database.
- Create and manage databases and their related components.

Solution Preview

This project is a good exercise to use SQL joins and typical query usage.

Solution ITCO630_P5.SQL uses the USE database statement.

1. Using a join, get the full details of all the students who work on the mid-term exam assignment.

This is achieved by typical join between tables: [student], [Summary], [Assignment] and [School]
Note: all tables being joined by corresponding keys.
E.g. table [Student] joined by table [Summary] by Student_no.

Final solution:
SELECT A.student_no, A.student_fname,A.student_lname,D.school_name,D.city
FROM [DBO].[Student] AS A
INNER JOIN [dbo].[summary] AS B ON A.student_no = B.student_no
INNER JOIN [dbo].[assignment] AS C ON C.assignment_no = B.assignment_no
INNER JOIN [dbo].[school] AS D ON D.school_no = A.school_no
WHERE C.assignment_name ='Mid-term Exam'

2. Get the assignment names (duplicates eliminated) being worked on by students at Central University.

Using same solution above and added the condition: school_name = "Central University"
And one more key condition added is ...

$2.19