Lab 2
Lab 2
Lab 2
LAB# 02
Objective:
Introduction to SQL Server and SQL
Introduction
To build a web site that shows data from a database, you will need:
RDBMS
Page 1 of 5
Database Systems (SE-312A)
• A record, also called a row, is each individual entry that exists in a table. For example,
there are 91 records in the above Customers table. A record is a horizontal entity in a
table.
• A column is a vertical entity in a table that contains all information associated with a
specific field in a table.
SQL Process:
When you are executing an SQL command for any RDBMS, the system determines the
best way to carry out your request and SQL engine figures out how to interpret the task.
Tables
• The data in RDBMS is stored in database objects called tables. A table is a collection of
related data entries and it consists of columns and rows.
• Every table is broken up into smaller entities called fields. The fields in the Customers
table consist of CustomerID, CustomerName, ContactName, Address, City, PostalCode
and Country. A field is a column in a table that is designed to maintain specific
information about every record in the table.
Page 2 of 5
Database Systems (SE-312A)
• A record, also called a row, is each individual entry that exists in a table. For example,
there are 91 records in the above Customers table. A record is a horizontal entity in a
table.
• A column is a vertical entity in a table that contains all information associated with a
specific field in a table.
In relational database systems (DBS) data are represented using tables (relations). A query issued
against the DBS also results in a table. A table has the following structure:
Example Database
In the following example we use a demo database to manage information about Customers.
DEPT table:
Page 3 of 5
Database Systems (SE-312A)
and
The columns to be selected from a table are specified after the keyword select. This
operation is also called projection. For example 1.1,
It lists only the name and the IDs for each tuple from the relation Customer.
The WHERE clause is used to extract only those records that fulfill a specified criterion.
Page 4 of 5
Database Systems (SE-312A)
SQL ORDER BY Syntax
SELECT column_name, column_name
FROM table_name
ORDER BY column_name ASC|DESC, column_name ASC|DESC;
Lab Tasks:
1. Open SQL Server Management Studio, Login with sa and password 123.
2. Run the example 1.1 query and record the results.
3. Display ids, names and addresses from Customers table.
4. Display the record of Customers who lives in London.
5. Display names, ids countries of Customers sorted by Country.
Page 5 of 5