LABORATORY EXERCISE 4 Prince Joseph Sales

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Ramon Magsaysay Memorial College

LABORATORY EXERCISE
____ SEMESTER: AY: _________

Name: Prince Joseph Sales__________ Schedule: __ Score: ________


Subject: _Fundamentals of Database Systems_Instructor: _Jim Jamero_______ Date: _________

LABORATORY EXERCISE 4
SQL JOINS

Learning Objectives
 To visualize and understand the SQL JOINS script.
 To determine the importance of JOINS and handling data.

Prerequisite student experiences and knowledge


Database management has evolved from a specialized computer application to a central
component of a modern computing environment. As a result, knowledge about database
systems has become an essential part of computer science.

Background
SQL (Structured Query Language) is a nonprocedural language, and you specify what
you want, not how to get it. A block-structured format of English keywords uses in this Query
language. It has the following components. The SQL DDL (Data Definition Language) provides a
command for defining relation schemas, deleting relations, and modifying relation schema.
DML (Data Manipulation Language) includes commands to insert tuples into, delete tuples
from and modify tuples in the Database. Embedded and Dynamic SQL define how SQL
statements can embed within general-purpose programming languages, such as C, C++, JAVA,
COBOL, Pascal, and Fortran.

Materials/Resources
 PC/Internet
 Pen
 MySQL (Xampp, Wampp & MySQL)
 Web Browser (Internet Explorer, Mozilla, Google Chrome, Etc.)
 Word-processing program

Laboratory Activity
Instructions: Perform the following steps.
1. Open the program Xampp
2. Click the Start for Apache and MySQL
3. Then, click MySQL Admin
4. Select Database, then click the Database created on laboratory exercise 1/2
5. Select the SQL menu, then
6. Type
CREATE TABLE Bus_Company ( Company_ID int,Company varchar(128), Bus_No
int(15));

FUNDAMENTALS OF DATABASE SYSTEMS 2 | Jim S. Jamero, MIT


1
Ramon Magsaysay Memorial College
LABORATORY EXERCISE
____ SEMESTER: AY: _________

Name: Prince Joseph Sales__________ Schedule: __ Score: ________


Subject: _Fundamentals of Database Systems_Instructor: _Jim Jamero_______ Date: _________

7. Insert data like sample below:

Company_ID Company Bus Number


COMP_0001 Yellow Bus BUS59
COMP_0002 Mindanao Star BUS60
COMP_0004 Husky BUS61
COMP_0003 Mindanao Star BUS62
COMP_0012 Yellow Bus BUS63

8. Select SQL menu, then type "SELECT * FROM bus CROSS JOIN Bus_Company."
9. If you encounter the Error, then fix the Error
10. Display the result.
11. Print the result on the page provided.

QUESTIONS

1. What is the result of "SELECT * FROM bus CROSS JOIN Bus_Company"? Explain the
result.

- The result in Cross join bus company is that all tables that were created in Bus and
Bus_company were added into one table.

2. Base on the resulting syntax below? What is the result of this syntax? How the data
process and show the result? How did you fix it if you encounter Error?
SELECT company_id, company, bus_number FROM bus CROSS JOIN where
company=Husky

- The result of the syntax shows all bus company with the Bus named “husky”.
The error in this code is the company_id, company, bus_number and I just removed
it and run the syntax

FUNDAMENTALS OF DATABASE SYSTEMS 2 | Jim S. Jamero, MIT


2
Ramon Magsaysay Memorial College
LABORATORY EXERCISE
____ SEMESTER: AY: _________

Name: Prince Joseph Sales__________ Schedule: __ Score: ________


Subject: _Fundamentals of Database Systems_Instructor: _Jim Jamero_______ Date: _________

Output / Results

FUNDAMENTALS OF DATABASE SYSTEMS 2 | Jim S. Jamero, MIT


3
Ramon Magsaysay Memorial College
LABORATORY EXERCISE
____ SEMESTER: AY: _________

Name: Prince Joseph Sales__________ Schedule: __ Score: ________


Subject: _Fundamentals of Database Systems_Instructor: _Jim Jamero_______ Date: _________

Conclusion

In this activity it shows you how to create a new table and do the cross join syntax in
the two tables and finding a specific bus name.

FUNDAMENTALS OF DATABASE SYSTEMS 2 | Jim S. Jamero, MIT


4

You might also like