Structured query language

1- Why is it important to learn SQL? In which jobs you need to know SQL?

SQL is Structured Query Language. It is used to modify the accessed database. The importance of learning SQL is to enhance your universal language. This helps to stimulate and learn other languages like C++ and python. It is also a large known by the community, making it easy to learn and use compared to other languages. SQL helps in the management of huge data records, which cannot be done by traditional spreadsheets. Some of the SQL jobs are being a database administrator, server management specialist, software developer, and even website designer.

2A- What is the definition of DML and DDL? Give examples in each case.

DML is the Data Manipulation Language that is used in SQL to manipulate data in a database. It includes an asset of commands that allows the user to retrieve existing data, delete data from files, and insert data. Examples of DML are select, delete, update, and insert.

DDL is a Data Definition Language. It is used to create and modify database structures like tables, views, etc. They are also used to describe records are files in a database. Examples of DDL are Create, Alter, and Drop.

2B- Consider the following two tables below: VENDOR and PRODUCT.

Write a SQL statement for each of the below:

  1. Show all Vendor names, vendor phone numbers in VENDOR table.

SELECT V-NAME, V-PHONE

FROM VENDOR

OUTPUT

 

V-NAME V-PHONE
Bryson, inc 223-3234
SuperLoo, inc 215-8995
D&E Supply 228-3245
Gomez Bros 889-2546
Dome Supply 678-3998
Randsets LTD 228-1410
Brackman Bros 898-1234
ORDVA, inc 227-0093
Damal Suppliers 890-3529
Rubicon Systems 456-0092

 

 

  1. Show all products sold by Gomez Bros.

SELECT V-CODE, V-NAME, P-CODE, P-DESCRIPT

FROM VENDOR*PRODUCT

WHERE V-NAME=’Gomez Bros’

INNER JOIN VENDOR ON PRODUCT=PRODUCT.VENDOR

OUTPUT

V-CODE V-NAME P-CODE P-DESCRIPT
21344 Gomez Bros 13-Q2/P2 7,25-in, pwr, saw blade

 

  1. c) Show all products with a price of greater than $100.

SELECT P-CODE, P-PRICE

FROM PRODUCT

WHERE P-PRICE=

(SELECT >$100 (P-PRICE) FROM PRODUCT 😉

OUTPUT

P-CODE P-PRICE
11QER/31 109.99
2232/QTY 100.92
89-WFE-Q 256.99
WR3/TT3 119.95

 

 

 

 

 

 

 

 

 

 

 

 

References

Date, C. J. (2011). SQL and relational theory: how to write accurate SQL code. “O’Reilly Media, Inc..”

Beaulieu, A. (2009). Learning SQL: Master SQL fundamentals. “O’Reilly Media, Inc..”

error: Content is protected !!