You are on page 1of 3

MN405 Data and Information Management

Laboratory 5: Introduction to SQL

Submission Due: End of laboratory class, submit the file on Moodle at least 10 minutes
before the end of laboratory class.

Total Marks = 5 marks for 10 weeks

Marks will be given only to students who attend and participate during 2 hours laboratory
class. Submission on Moodle is mandatory as an evidence of participation.

Description of the laboratory exercise:

The purpose of this assignment is to introduce Database concepts such as entity, attributes,
Primary key and relationships..

Exercises

Download this Laboratory exercise to your hard drive, write your answers and upload
on to the Moodle submission link.

1. First download the database file called "TAL_Distributors" available on Moodle on


to your hard drive.

a. Open the file in Microsoft Access. We will be using this database file in first
few weeks’ laboratory classes.

b. Examine the relations (tables) in this database, by double clicking on them.


You can switch between Datasheet view and Design View (the table's schema)
by clicking on the buttons on the bottom right corner.(See Figure1)

Figure 1 To go to Design View click this button

c. How many relations are there in the "TAL_Distributors" database? Click on


“Database Tool -> Relationships”

Prepared by: Dr. Deepani Guruge Moderated By: Prof. Savitri Bevinakoppa T1, 2021
MN405 Data and Information Management Page 2 of 2

d. Fill the following table by opening the relations/ tables by double clicking on
them.

Name of the No of attributes Names of the attributes


relation/Table

1. customer 9 CustomerNum,
CustomerName……
2. …
3. ...

Table 1

2. Open each relation and move to design view by clicking buttons on the bottom
right corner.
a. Identify the data type of each attribute(Field name) in Design view

Figure 2: Design View

b. Now add a new column to table1 above, created in question 5 and name it as
Primary Key. Find the Primary key of each table and enter.

Figure 3: Primary Key - in the Design View

Every table in your database should have a Primary key. Primary key is a
column or collection of columns of a table (relation) that uniquely identifies a
given row in that table.

c. Enter new field “Age”, to customer table. You need to Click on the design
view.
d. Change the primary key of “Customer” table to “customerName”. This is not
easy. You can’t change the Primary when it is joined
e. Select data sheet view and enter data into this new “Age” field.

3.
 Open query window in Microsoft Access. to create queries
1. To create a new query, click CREATE on the ribbon to display the CREATE
tab,

Prepared by: Dr. Deepani Guruge Moderated By: Prof. Savitri Bevinakoppa T1, 2021
MN405 Data and Information Management Page 3 of 3

2. Then click the Query Design button in the Queries group to create a query
and click the Close button in the Show Table dialog box.
3. Click the View button arrow in the Results group on the QUERY TOOLS
DESIGN tab and then click SQL View.
4. Now you can create the query.
5. To run the SQL Command, click the Run button in the Results group on the
QUERY TOOLS DESIGN tab.

Write queries to

o List the complete Customers table.

o List the complete item table.

o List the numbers and names of all customers.

o List the number and name of all customers that are represented by rep 15.

o List the number and name of all customers that are represented by rep 15 and
that have a credit limit of $10,000.

4. Close "TAL_Distributors" database.

Create new database called “Academic”. Add 2 tables; Student and Mark tables with
suitable attributes to the Academic database. Populate those tables with suitable data
records (at least 3 records per table).

Prepared by: Dr. Deepani Guruge Moderated By: Prof. Savitri Bevinakoppa T1, 2021

You might also like