0% found this document useful (0 votes)
62 views

Lab 1 Introduction To SQL Tools and Technique

This document provides an introduction to the tools and techniques used for relational database management. It discusses web architecture including clients, servers and databases. It also covers topics like data definition language, data manipulation language, data control language and tools used for client-side development, server-side scripting and database management.

Uploaded by

rida.maryam1215
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Lab 1 Introduction To SQL Tools and Technique

This document provides an introduction to the tools and techniques used for relational database management. It discusses web architecture including clients, servers and databases. It also covers topics like data definition language, data manipulation language, data control language and tools used for client-side development, server-side scripting and database management.

Uploaded by

rida.maryam1215
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Capital University of Science and Technology, Islamabad

Department of Computer Science,


Faculty of Computing

Lab Manuals for Introduction to Database Systems


V1.2 (CS1131)

Contribution

The manual was last updated on January 14, 2022 by:


Ms. Mariam Munsif (Reviewed + Revised) and Mr. Ehtasham Ali (Revised)
Capital University of Science and Technology, Islamabad
Department of Computer Science,
Faculty of Computing

Lab Outline

Week Labs
1 LAB 1 – Introduction to SQL Tools and Technologies
2 LAB 2 - Introduction to HTML, CSS and Forms
3 LAB 3 – PHP Introduction and Forms Handling
4 LAB 4 – Database Connectivity and DDL Introduction
5 LAB 5 - Data Defination Language
6 LAB 6 - SQL DML (INSERT, UPDATE, DELETE, SELECT INTRODUCTION)
7 LAB 7 - View, Update and Delete Operation using Web Interface
8 LAB 8 - Data Manipulation Language (SELECT WHERE, ORDER, DISTINCT, LIMIT)
9 LAB 9 - SQL SELECT with functions, aggregate functions
10 LAB 10 - GROUP BY AND HAVING
11 LAB 11 - SQL JOINS INNER SELF OUTER
12 LAB 12 - SQL OUTER JOINS LEFT and RIGHT JOIN
13 LAB 13 - SQL SubQueries with ALL, ANY, EXISTS, SOME
Lab Manual for Introduction to Database Systems
Lab-01
Introduction to SQL Tools and Techniques
Lab 0: Introduction to SQL Tools and Techniques

Contents

1. Introduction 5

1.1 Relevant Lecture Material: 5

2. Activity Time boxing 5

3. Objective of the experiment 5

4. Concept Map 5

4.1 Web Architecture: 6

4.2 Tools and Techniques: 6


• Data Definition Language 8
• Data Manipulation Language 9
• Data Control Language 9

5. Homework before Lab 9

5.1 Task 1 9

5.2 Task 2 9

6. Procedure & Tools 9

6.1 Walkthrough Tasks 1 (Installing PhpStorm tool): 9

6.2 Walkthrough Tasks 2 (Installing and Configuring XAMPP (MySQL,


Apache) ) 18

6.3 Walkthrough Tasks 3 (Configuring the Environment Variable ) 21

7. Practice Task 3

8. Evaluation Task (Unseen) [Expected time = 30mins for tasks] 3

9. Evaluation criteria 3

10. Further Reading 3

10.1 Slides 3

Department of Computer Science, Page 4


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

Lab 01: Introduction to SQL Tools Techniques


1. Introduction
In introduction to database course, you are learning databases, database models, and database
management systems, particularly relational data model and relational database management
system (RDBMS). In this first lab, you will get familiar with the tools and techniques required for
database management systems. You will use XAMPP application stack that includes MySQL
Database Server, Apache Web Server, PHP interpreter, MySQL CLI (Command Line Interface)
and PHPMyAdmin as a management system for MySQL Server.

1.1 Relevant Lecture Material:


a) Text Book: Database Systems, A practical approach to design, implementation,
and management by Thomas Connolly, Carolyn Begg, Addison Wesley, Fifth
Edition,
b) Read URL:
i. https://www.wikihow.com/Install-XAMPP-for-Windows
2. Activity Time boxing

Task No. Activity Name Activity time Total Time

4 Introduction 60 mins 60 mins


6 Installing Notepad++ and 60mins 60mins
xamp
7 Practice tasks 40 mins 40mins
Table 1: Activity Time Boxing

3. Objective of the experiment


• To learn about the WebArchitectures.
• To know about the tool and techniques required for database management.
• To learn the installation, setup, and usage of tools required for relational database
management.

4. Concept Map
In this section, first a brief overview of the Web Architecture is presented, then we will study
about the role of database in Web Architecture. After that we discuss the tools and technique
required for database.

Department of Computer Science, Page 5


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

4.1 Web Architecture:

The above diagram is a generic Web Architecture. There are three main component of the web
architecture system which are given below:
4.1.1 Client/User:
In web architecture the client/user request for some data from server by using the frontend of the
application. The frontend of the application is built by usingHTML, CSS etc.
For example: we can see in the above diagram that inStep 1client request for the website of
CUST University by providing the link of a website in a browser. In Step 2the request of client
go to the server by using Internet.
4.1.2 Server:
In web architecture the server (Apache Web Server)that accepts the client's requests and process
the request and provides the required data as response.
For example: In the above diagram we can see that in Step 3the server accept the request of a
client and process them by using PHP as a scripting language. In Step 4the server access the
requested file by using server port 80.
4.1.3 Database:
Databases are used for storing and managing data. These databases are installed on server. The
server ensure the accessibility of data from these databases against client request.
For example: In the above diagram we can see that in Step 5 if the request file contain data
related query, the server request from database by using port 3306. The request of data written in
SQL language. In Step 6 the requested data is returned by database to the server. At last in Step
7, the server return the requested file to the client which is in the form of HTML and CSS.

4.2 Tools and Techniques:


In this section we have discussed some basic terminologies of tools and techniques related to this
course.Generally, we will divide this course in three different parts. First we will briefly discuss
Client side, followed by server side and the next one is database which is the main part of this
course.
4.2.1 Client:

Department of Computer Science, Page 6


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

In web development, 'client side' refers to everything in a web application that is displayed or
takes place on the client (end user device). This includes what the user sees, such as text, images,
and the rest of the UI, along with any actions that an application performs within the user's
browser.
Markup languages like HTML and CSS are interpreted by the browser on the client side, which
will be discussed in next lab. These languages are used to develop to the client side interfaces.
✓ Tools:
For writing the code of these languages we can use multiple tools such as: 1) Notepad, 2)
Notepad++, 3) PHP Stormetc, which is openly available on internet. You can just download it
and install on your system. Below are some references which can help you in downloading and
installing these tools.
• https://notepad-plus-plus.org/downloads/
• https://www.jetbrains.com/phpstorm/download/#section=windows
4.2.2 Server:
Web browsers communicate with web servers using the HyperText Transfer Protocol
(HTTP). When you click a link on a web page, submit a form, or run a search, an HTTP
request is sent from your browser to the target server.
The request includes a URL identifying the affected resource, a method that defines the required
action (for example to get, delete, or post the resource), and may include additional information
encoded in URL parameters (the field-value pairs sent via a query string), as POST data (data
sent by the HTTP POST method), or in associated cookies.
Web servers wait for client request messages, process them when they arrive, if there is some data
related request so get the data from database and reply to the web browser with an HTTP
response message.
The body of a successful response to a request would contain the requested resource (e.g. a new
HTML page, data, or an image, etc...), which could then be displayed by the web browser.
For doing all of this process we have to use some server side scripting languages. The most
popular server-side scripting languages and frameworks include PHP, ASP.NET, Node. js, Java,
Ruby, Perl and Python. These scripts run on a web server and respond to client requests via
HTTP to deliver dynamic and customized content to the user.
✓ Tools:
• PHP:
We will use a PHP as a server-side scripting language it is one of the powerful tool for making
dynamic and interactive Web applications. Moreover, it is widely-used, free, and open source
language. For writing the code of PHP we can use multiple tools such as: 1) Notepad, 2)
Notepad++, 3) PhpStormetc, which is openly available on internet. You can just download it and
install on your system. Below are some references which can help you in downloading and
installing these tools.
o https://notepad-plus-plus.org/downloads/
o https://www.jetbrains.com/phpstorm/download/#section=windows

Department of Computer Science, Page 7


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

• XAMPP:
XAMPP is a free and open-source cross-platform web server solution stack package developed by
Apache Friends, consisting mainly of the Apache HTTP Server, Maria DB database, and
interpreters for scripts written in the PHP and Perl programming languages.
4.2.3 Database:
Database is the main part of this course that exist on web server. In this section, a brief overview
of the database related terminology is presented.

• Relational Data Model:


Relational data model is the primary data model, which is used widely around the world for data
storage and processing. This model is simple and it has all the properties and capabilities required
to process data with storage efficiency.
In relational data model, relations are saved in the format of Tables. This format stores the
relation among entities. A table has rows and columns, where rows represents records and
columns represent the attributes.
• Database Management System (DBMS):
A database management system (DBMS) is a computer software application that interacts with
the user, other applications, and the database itself to manage data in databases. A general-
purpose DBMS is designed to allow the definition, creation, querying, update, and administration
of databases.

• Relational Database Management System (RDBMS):


A relational database management system (RDBMS) is a database management system (DBMS)
that is based on the relational model.

• SQL (Structured Query Language):


SQL (Structured Query Language) is the standard language used for the retrieval and
management of data in relational databases (RDBMS). It also supports database schema
definition and modification. It is supported by all modern database management systems (e.g.
Oracle, IBM DB2, Microsoft Access, Microsoft SQL Server, PostgreSQL, MySQL, etc.).
SQL is based on the relational model. The basic data structure in RDBMS is a table. SQL
provides you the features to define tables, define constraints on tables, query for data in the table,
and change the data in the table by adding, modifying, and removing data. SQL also supports
grouping of data in multiple rows, combining tables and other features.
SQL is high-level declarative language, quite easy to learn, allowing complex tasks on a database
to be specified simply. SQL has a defined syntax that specifies how standard keywords can be
combined to form valid SQL statements. SQL statements can be divided into three categories,
according to their function:
• Data Definition Language
Statements that create, modify or destroy database objects (such as tables). These statements
begin with the keywords: CREATE, ALTER or DROP.

Department of Computer Science, Page 8


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

• Data Manipulation Language


Statements that retrieve, insert, update, edit or delete data stored in database tables. These
statements begin with the keywords: SELECT, INSERT, UPDATE or DELETE.

• Data Control Language


Statements that authorize certain users to view, change or delete data. These statements begin
with the keywords: GRANT or REVOKE. We do not consider data control in the lab exercises.

• MySQL:
MySQL is a free, open-source, and the most popular relational database management system
(RDBMS).

• PHPMyAdmin:
PHPMyAdmin is a free and open source tool written in PHP intended to handle the
administration of MySQL with the use of a web browser.

5. Homework before Lab


You must solve the following problems at home before the lab.

5.1 Task 1
Study HTML Tags used for creating web interfaces.

5.2 Task 2
Study about CSS and its types used for designing web interfaces.

6. Procedure & Tools


In this section, procedure of the tasks and setup of required tools is defined.

6.1 Walkthrough Tasks 1 (Installing PhpStorm tool):


This tool is used for coding client side language and server side scripting language.

• Download PhpStorm
fromhttps://www.jetbrains.com/phpstorm/download/#section=windows

• After downloading double click on .exe file the first window appear which is somehow like
given below figure:

Department of Computer Science, Page 9


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

Figure 1: Welcome Panel

• For proceeding Installation just click on Next button. After clicking the PhpStorm
installation starts with a splash screen, see Figure 2.

Figure 2: PhpStorm Setup

Department of Computer Science, Page 10


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

Give the path where you want to install PhpStorm, and Click Next button

• Now you can a check a bit launcher check box according to your system specification and
ignore other options which are not required now. Click Next Button

Figure 3: Installation Options

• You can create a shortcut folder for Phpstorm. But now in figure 4 you just click install
button to start the installation

Department of Computer Science, Page 11


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

Figure 4: Start Menu Folder

• Now installation you will wait for couple of minute.

Figure 5:Installation window

Department of Computer Science, Page 12


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

• Now your PhpStorm installed successfully, if you want to run check the checkbox and
click on finish button, see figure 7

Figure 6: Finish Installation

• Now when you clicking on Finish button the PhpStrom start with the following splash
Screen. You just click Do not import setting radio button and click Ok button

Figure 7: Setting PhpStorm

Department of Computer Science, Page 13


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

• Now just readout the agreement and click on Accept button.

Figure 7: License Agreement

• Now for the time being we use phpstorm trial version so click. Evaluate for free radio
button and Evaluate button.

Figure 8: License Activation

Department of Computer Science, Page 14


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

• Now just readout the license agreement and click on Accept button.

Figure 9: License Agreement

• Select your Desired theme

Figure 10: Theme Selection

Department of Computer Science, Page 15


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

• Now Click Start using PhpStorm button.

Figure 11: Start up Window

• Now you will create the project by clicking Create New Project option.

Department of Computer Science, Page 16


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

Figure 12: Creating Project

• Give Project name and click on create button

Figure 13: Give project Name

Department of Computer Science, Page 17


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

• Now you are ready to code in PhpStorm

Figure 14: Code Window

6.2 Walkthrough Tasks 2 (Installing and Configuring XAMPP (MySQL, Apache) )


• Download XAMPP from http://www.apachefriends.org/en/xampp.html. XAMPP for
Windows exists in three different flavors. The “Installer” version is “probably the most
comfortable way to install XAMPP” according to the XAMPP website.
• Start the XAMPP installation. Note that Windows 7,8, and 10 will warn that installing to
the Program Files directory will keep XAMPP from being able to write to its directory
due to UAC see Figure 9. Disabling UAC is not recommended. XAMPP can be installed
to C:\XAMPP to avoid this issue or XAMPP can be given permission to run as
Administrator.

Figure 15: UAC Warning

• The XAMPP installation starts with a splash screen, see Figure 10. Click “Next”.

Department of Computer Science, Page 18


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

Figure 16: XAMPP Setup Wizard 6.1.2.2

• Select the tools you want to install, see Figure 11.

Figure 17: XAMPP Options

Department of Computer Science, Page 19


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

• Choose which directory to install XAMPP. In Figure 12, It is being installed in a directory
xampp under drive D.

Figure 18: Xampp Startup

• Click Next to complete the installation. It may take a while. After the completion, it
prompts with a dialogue box, see Figure 13. Click “Yes” Button.

Figure 19:Setup Complete Popup

• The XAMPP installation completes. The XAMPP control panel can be started. Start
Apache and MySql by clicking the start button next to them, see Figure 14.

Department of Computer Science, Page 20


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

Figure 20: XAMP Control Panel

If Apache gives the error “Port 80 is in use by “Some Other Process” with PID X!”, we would
have to change the port see Appendix II.

6.3 Walkthrough Tasks 3(Configuring the Environment Variable )


To run MySQL CLI, the path to MySQL bin folder is required to be configured in an
environment variable named PATH. To make windows’ console aware of the MySQL tools.
Following are the steps to configure PATH variable for MySQL tools.

• Go to Control Panel > System and Security > System and Click Advanced system
settings, See Figure 15.

Figure 21: Advance System Settings

Department of Computer Science, Page 21


C.U.S.T.
Lab 0: Introduction to SQL Tools and Techniques

• Click Environment Variables, See Figure 16.

Figure 22: System Properties

• Variable name PATH is available double click it, otherwise click NEW, See Figure 17.

Figure 23: Environment Variables

• Copy Path to MySQL > BIN folder from inside your XAMPP installation folder, See
Figure 18.
Page | 1
Lab 0: Introduction to SQL Tools and Techniques

Figure 24: Path of bin folder

• Paste the copied path in Variable Value field for the Variable Name PATH. See Figure
19.

Figure 25: Edit User Variable

• Open Statement prompt and Write statement MySQL then press Enter key, See Figure
20.

Page | 2
Lab 0: Introduction to SQL Tools and Techniques

Figure 26: Statement Prompt for starting MySQL

7. Practice Task
• Visit w3school.com and start studying about HTML and CSS and make report about
HTML Tag and CSS and its types. The report contains tags and their description.

8. Evaluation Task (Unseen) [Expected time = 30mins for tasks]

The lab instructor will give you unseen task depending upon the progress of the class.

9. Evaluation criteria
The evaluation criteria for this lab will be based on the completion of the following tasks. Each
task is assigned the marks percentage which will be evaluated by the instructor in the lab
whether the student has finished the complete/partial task(s).
Table 6: Evaluation of the Lab
Sr. No. Task No Description Marks

1 6 Procedures and Tools 05


2 6 Walkthrough task 15
3 7 Practice Task 80
10. Further Reading

This section provides the references to further polish your skills.

10.1Slides

The slides and reading material can be accessed from the folder of the class instructor available
at \\fs\lectures$\
11. REFERENCES:

• SQL-99 Complete, Really, by Peter Gulutzan& Trudy Pelzer


Appendix I

Page | 3
Lab 0: Introduction to SQL Tools and Techniques

While starting the Apache server, if port default port (80) is already being used by some other
application, it would display an error in XAMPP Control Panel as shown in Figure 23. We can
change the port by performing the following steps,

1.Open The XAMPP control panel from C:\xampp\xampp-control.exe.

Figure 3: Xampp Startup

In 80 is in use then you will click on “Config” button infront of “Apache”, select “httpd.conf”
from the menu. Httpd.conf file will be opened in NotePad, Find “Listen 80” and change the port
80 to someother value of your choice. i.e. 8082.

Page | 4
Lab 0: Introduction to SQL Tools and Techniques

Figure 4

Figure 5

In 443 is in use then you will click on “Config” button infront of “Apache”, select
“httpdssl.conf” from the menu.
Httpd-ssl.conf file will be opened in NotePad, Find “Listen 443” and change the port 443 to
someother value of your choice. i.e. 444,

Page | 5
Lab 0: Introduction to SQL Tools and Techniques

Figure 6

Figure 7

Page | 6
Lab 0: Introduction to SQL Tools and Techniques

Figure 8

11.1.1.1Start Apache and MySql:

Figure 9

Page | 7
Lab 01: Introduction to SQL Tools and Data Definition Language (CREATE)

Department of Computer Science, Page 1


C.U.S.T.

You might also like