100% found this document useful (1 vote)
289 views

ISM Lab File

This document defines key concepts related to databases and database management. It defines data, information, databases, database management systems (DBMS), and relational database management systems (RDBMS). It also provides steps to open Microsoft Access and create a database, including the various elements of a database like tables, fields, records, forms, filters, queries, and reports. Finally, it discusses the features of SQL and defines it as a language for retrieving and managing data from relational databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
289 views

ISM Lab File

This document defines key concepts related to databases and database management. It defines data, information, databases, database management systems (DBMS), and relational database management systems (RDBMS). It also provides steps to open Microsoft Access and create a database, including the various elements of a database like tables, fields, records, forms, filters, queries, and reports. Finally, it discusses the features of SQL and defines it as a language for retrieving and managing data from relational databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 115

Information System Management

PRACTICAL - 1
Q) Define Data Information, Database, DBMS and RDBMS.
DATA - Data is any sort of information which is stored in computer memory. This information can later be used
for a website, an application or any other client to store for future purpose. The most common information is User
information in the form of user personal, address and banking information. Let’s consider Facebook, it stores our
personal data, images, posts, comments and many more things. Banking application also stores user data, their
transactions details, funds summary etc. All this information is data, but when it put together and store in a
structural way, it becomes informational data.

DATABASE - Database (DB) are organized, they have a structure, and all the data they store it fits into that
structure. More specifically, a database is an electronic system that allows data to be stored, easily accessed,
manipulated and updated. Databases are quite similar to spreadsheets as they are mostly made up of tables which
contain rows and columns like a spreadsheet. A database needs to be hosted or created on some special database
platform, some of the famous Database platforms are:

● PostgreSQL
● MySQL
● Microsoft Access
● SQLite

Database Management System -A database management system is a software used to perform different
operations, like addition, access, updating, and deletion of the data, like adding your name in the database for an
online retail store as a customer. A database management system acts as the backbone of a database and makes
using a database a cakewalk as it makes access and management of data a lot easier.

RDBMS - RDBMS. Stands for "Relational Database Management System." An RDBMS is a DBMS designed
specifically for relational databases. Therefore, RDBMSes are a subset of DBMSes. A relational database refers to
a database that stores data in a structured format, using rows and columns.

ADITYA DAS 1 40221101718


Information System Management

PRACTICAL – 2
Q) Give steps to Open Microsoft Access. Write steps to create a database. What are the
various elements of a database? What are the various ways to create tables in databases ?
Microsoft Access is a Database Management System offered by Microsoft. It uses the Microsoft Jet Database
Engine and comes as a part of the Microsoft Office suite of applications .

Microsoft Access offers the functionality of a database and the programming capabilities to create easy to navigate
screens (forms).

Steps to open MS ACCESS are :-

Step 1) Click on the 'Windows' icon. You will find the list of installed programs.

Step 2) Check and click on Access Icon.

ADITYA DAS 2 40221101718


Information System Management

Step 3) MS Access Application window will appear

TO CREATE A DATABASE IN ACCESS:

Step 1) Open microsoft access

Step 2) Access displays a variety of database templates you can use

Step 3) Select blank database and enter the name in file name field

ADITYA DAS 3 40221101718


Information System Management

Step 4) After entering file name click create option. Access will download that database template and open a
new blank database as shown in the following screenshot.

ADITYA DAS 4 40221101718


Information System Management

VARIOUS ELEMENTS OF DATABASE ARE:

● Tables
● Fields
● Records

Tables
A database table is composed of records and fields that hold data. Tables are also called datasheets. Each table in a
database holds data about a different, but related, subject.

Fields
A field is part of a record and contains a single piece of data for the subject of the record. In the database table
illustrated in Figure 4, each record contains four fields:
Log ID A number assigned to this customer support incident for
identification purposes
Operator The code for the customer support operator who handled
this incident
Resolved A check box to indicate whether the incident was resolved
Duration The time in seconds the operator spent on this incident

Fields appear as columns in a database table.

ADITYA DAS 5 40221101718


Information System Management

Records
Data is stored in records. A record is composed of fields and contains all the data about one particular person,
company, or item in a database. In this database, a record contains the data for one customer support incident
report. Records appear as rows in the database table.

Forms
A database form shows all or selected fields for one record. Forms show field names and data in an attractive and
easy-to-read format.

you can enter data in fields in a form just as you can in a table. Navigation buttons for moving from record to
record are displayed at the bottom of the form.

ADITYA DAS 6 40221101718


Information System Management

Filters
A filter displays records in a database according to criteria you select. Although the database used as an example in
this seminar is small, a database can contain a large amount of data. You might want to filter the data, hiding some
records and displaying others. For example, you might want to display records for Operator CS1 only. A filter
allows you to do so easily.

The other records are still in the table even though they are not displayed. The filter can be removed to display all
the records in the table.

Queries
A query finds records in a database according to the criteria you specify. Sometimes working with all the data in a
large database is not practical. You might wish to work with just a small part or subset of the data. For example,
you might want to find records for unresolved customer support incidents. A query can be used to display these
records. You could construct the query to display only selected fields, such as Log ID and Resolved. A query
displays only the data you request.

ADITYA DAS 7 40221101718


Information System Management

Only the Log ID and Resolved fields for unresolved incidents are displayed.

Reports
A report presents data in an attractive format and is especially suitable for printing. Reports can display data from
tables or queries. All or selected fields can be included in a report. Data can be grouped or sorted and arranged in a
variety of ways.

ADITYA DAS 8 40221101718


Information System Management

VARIOUS WAYS TO CREATE TABLE IN DATABASE:

There are two ways to create Database in MS ACCESS

1. Create a Table from Design View


2. Create a Table from Datasheet View

Create Table – Datasheet View


Step 1) First Click the Create tab. Then from the Tables group, click Table.

Step 2) System will display the default table created with 'Table1' name.

ADITYA DAS 9 40221101718


Information System Management

3) To Rename Column, double click on Column Header and enter the new column Name.

Step 4) You can also add a column by clicking on 'Insert Column'

ADITYA DAS 10 40221101718


Information System Management

Step 5) Columns will be added with the default name as 'Field1.'

Step 6) Click on Header and rename as 'COURSE_NAME.'

Step 7) Press 'Ctrl + S' and Enter the new table name to save the table.

ADITYA DAS 11 40221101718


Information System Management

Create Table – Design View


Step 1) First Click the Create tab. Then from Tables group, click Table.

Step 2) Table Dialog box appears. For each Field enter Field Name, Data Type and Description.

Steps 3) To Add Course ID as Primary Key, select it and Click on 'Primary Key.' Course Id will be Preceded by
KEY ICON as shown below:

ADITYA DAS 12 40221101718


Information System Management

Steps 4) Press 'Ctrl+S.' Enter the Table Name and Click OK

ADITYA DAS 13 40221101718


Information System Management

PRACTICAL- 3
Q) Write down the features of SQL and Define also.
SQL is a database computer language designed for the retrieval and management of data in a relational database.
SQL stands for Structured Query Language. This tutorial will give you a quick start to SQL. It covers most of the
topics required for a basic understanding of SQL and to get a feel of how it works.

FEATURES

● High Performance
o SQL provides high performance programming capability for a highly transactional, heavy workload and
high usage database system. SQL programming gives various ways to describe the data more
analytically.
● High Availability
o SQL is compatible with databases like MS Access, Microsoft SQL Server, MySQL, Oracle Database,
SAP HANA, SAP Adaptive Server, etc. All of these relational database management systems support
SQL and it is easy to create an application extension for procedural programming and various other
functions which are additional features thus converting SQL into a powerful tool.

● Scalability and Flexibility


o SQL provides Scalability and Flexibility. It is very easy to create new tables and previously created or
not used tables can be dropped or deleted in a database.
● Robust Transactional Support
o SQL programming can handle large records and manage numerous transactions.

● High Security
o It is very easy to provide permissions on tables, procedures, and views hence SQL gives security to your
data.
● Comprehensive Application Development
o SQL is used by many programmers to program apps to access a database. No matter what the size of
organization, SQL works for every small or large organization.

PRACTICAL- 4
Q) Give the steps to create a table in design view and datasheet view.
Create Table – Datasheet View
Step 1) First Click the Create tab. Then from the Tables group, click Table.

ADITYA DAS 14 40221101718


Information System Management

Step 2) System will display the default table created with 'Table1' name.

ADITYA DAS 15 40221101718


Information System Management

3) To Rename Column, double click on Column Header and enter the new column Name.

Step 4) You can also add a column by clicking on 'Insert Column'

Step 5) Columns will be added with the default name as 'Field1.'


ADITYA DAS 16 40221101718
Information System Management

Step 6) Click on Header and rename as 'COURSE_NAME.'

Step 7) Press 'Ctrl + S' and Enter the new table name to save the table.

ADITYA DAS 17 40221101718


Information System Management

Create Table – Design View


Step 1) First Click Create tab. Then from Tables group, click Table.

Step 2) Table Dialog box appears. For each Field enter Filed Name, Data Type and Description.

Steps 3) To Add Course ID as Primary Key, select it and Click on 'Primary Key.' Course Id will be Preceded by
KEY ICON as shown below:

ADITYA DAS 18 40221101718


Information System Management

Steps 4) Press 'Ctrl+S.' Enter the Table Name and Click OK

ADITYA DAS 19 40221101718


Information System Management

PRACTICAL-5

Q) Explain Field Name, Data Types, Field Size with its Description.

SOLUTION:

Field Name
Field name is the name of column. It should represent the contents of the field such as
“Name”, “Address” and “Final Grade” etc. the name of the field cannot exceed 64
characters in length. It many include spaces. The use of spaces in field name is not a
good practice.

Data Type
Each filed must be assigned a particular data type. The data type specifies the type of
data that can be stored in the field. Common data types in MS Access are Number, Text,
Currency and Date etc.

ADITYA DAS 20 40221101718


Information System Management

Field Size
Field size is used to set the number of characters required in text or number field. The
default field size for the text type is 50 characters. The field size can be limited to a
certain number of characters if value in field is small. It waves disk space and prevents
entry errors. The filed size is set in exact characters for Text type. The options for
numbers are as follows;

ADITYA DAS 21 40221101718


Information System Management

PRACTICAL-6

Q) Give the steps to open an existing database.


SOLUTION:

To open an existing database follow the steps given below

Step 1) Click on office button at the top of the screen.

Step 2) Click open, and select the location of existing database, a dialogue
box will appear.

Step 3) Choose the Database which you want to open and click on it.
ADITYA DAS 22 40221101718
Information System Management

ADITYA DAS 23 40221101718


Information System Management

PRACTICAL-7

Q) Create a student database with a table STUDENT_DETAILS containing the field name
as
• ID
• FIRST NAME
• LAST NAME
• AGE
• ADDRESS
Insert 5 records using the design view in MSACCESS.
Create another table using data sheet view as STUDENT_COURSE with the field name as
• ID
• COURSE CODE
• COURSE Name Enter 5
records.
SOLUTION: STUDENT_DETAILS

Design View

ADITYA DAS 24 40221101718


Information System Management

Datasheet View

STUDENT_COURSE

Design View

ADITYA DAS 25 40221101718


Information System Management

Datasheet View

ADITYA DAS 26 40221101718


Information System Management

PRACTICAL-8
Q) Steps to create a database, save the database and open the database. Create a
student database with S1 as table containing the field names as SERIAL NO,
ENROLLMENT NO, NAME, AGE and ADDRESS. Insert at least 10 records using the
design view in MS ACCESS.
SOLUTION: Student Database
Design View

Datasheet View

ADITYA DAS 27 40221101718


Information System Management

PRACTICAL-9
Q) Define data type and explain the various data types available in MS-ACCESS. Create a
database DB1 with a table T1 with the following fields as:
● ST_NO.
● ST_ID
● ST_NAME
● ST_ADD
● ST_PHONE NO.
● ST_HOBBIES
In the design view and add at least 10 records in the table.
SOLUTION:
Design View

ADITYA DAS 28 40221101718


Information System Management

Datasheet View

ADITYA DAS 29 40221101718


Information System Management

PRACTICAL-10
Q) Create a database named EMPLOYEE with the following fields as
EMPLOYEE NAME, EMPLOYEE CODE, EMPLOYEE DESIGNATION,
EMPLOYEE DEPARTMENT, DATE OF JOINING and YEAR OF
EXPERIENCE. Delete any two records as well as fields from the table
to show the output.
SOLUTION: Employee Database

Design View

ADITYA DAS 30 40221101718


Information System Management

Datasheet View

Deleted records

ADITYA DAS 31 40221101718


Information System Management

Deleted fields

ADITYA DAS 32 40221101718


Information System Management

ADITYA DAS 33 40221101718


Information System Management

ADITYA DAS 34 40221101718


Information System Management

PRACTICAL-11
Q) Create an EMPOYEE database with the following fields as
• Emp_code
• Emp_ssn
• Emp_name
• DOB
• Emp_design
• Emp_dept
• DOJ
• E_SAL
• Years of experience
For the above created database set the following fields properties:
1.Employee names should be in upper case with field size equal to10.
2.Set the default value of Emp_dept as HR.
3.Date of joining should be set to the current date by default.
4. E_SAL should be in dollars.

SOLUTION
Employee names should be in upper case with field size equal to10.

ADITYA DAS 35 40221101718


Information System Management

Set the default value of Emp_dept as HR

ADITYA DAS 36 40221101718


Information System Management

Date of joining should be set to the current date by default

ADITYA DAS 37 40221101718


Information System Management

E_SAL should be in dollars

ADITYA DAS 38 40221101718


Information System Management

PRACTICAL-12
Q) Create an EMPOYEE database with the following fields as:
• Emp_code
• Emp_ssn
• Emp_name
• Emp-dob
For the above created database set the input mask for the field property for Emp_ssn and
Emp_dob using the input mask wizard.
SOLUTION

ADITYA DAS 39 40221101718


Information System Management

ADITYA DAS 40 40221101718


Information System Management

PRACTICAL-13

Q) Create a table as STUDENT_DETAILS with the following fields

• S_id
• S_name
• S_course
• S_marks
• S_dob

Make S_id as the primary key and apply the following validations:
1.S_name should start with A and end with M.
2. S_course can have only BBA OR MBA as its values.
3. S_marks, it can be NULL or should be > 50.
4. S_dob should be less than the current date. Enter at least 10 entries in the table.

S_name should start with A and end with M

ADITYA DAS 41 40221101718


Information System Management

S_course can have only BBA OR MBA as its values

. S_marks, it can be NULL or should be > 50

ADITYA DAS 42 40221101718


Information System Management

S_dob should be less than the current date

ADITYA DAS 43 40221101718


Information System Management

PRACTICAL-14
Q) Create a database named as STUDENT DATABASE with a table STUDENT_DETAILS
having fields as
• St_id
• St_roll no.
• St_name
• St-age
• St-dob
• St_course
• St-add
• St_contact
• St_phone no.

Add at least 10 records in the table.

Answer the following:


A. What is a primary key? Make a field stu_id as the primary key in the table. Also write
down the steps for the same.
B. What is a composite key? In the table STUDENT_DETAILS, make stu_roll no and stu-
dob as a composite key also write the steps for the same.

(A) Primary key:- A column or group of columns in a table which helps us to uniquely
identifies every row in that table is called a primary key. This DBMS can't be a duplicate. The
same value can't appear more than once in the table.

 Rules for defining Primary key:


 Two rows can't have the same primary key value
 It must for every row to have a primary key value.
 The primary key field cannot be null.

ADITYA DAS 44 40221101718


Information System Management

 The value in a primary key column can never be modified or updated if any foreign
key refers to that primary key.
Step1:- Click on ‘view’ option then select ‘design view’

ADITYA DAS 45 40221101718


Information System Management

Step2:- select st_id and then click on primary key

(B) Composite key : A key that has more than one attributes is known as composite key. It is also
known as compound key..

STEP 1 Click on VIEW then Click on DESIGN VIEW.

STEP 2 Click on INDEXES.

STEP 3 Enter the field you want to make COMPOSITE KEY.


ADITYA DAS 46 40221101718
Information System Management

ADITYA DAS 47 40221101718


Information System Management

PRACTICAL-15
Q) Create a company database with the following table EMP_DETAILS with the fields as: •
EMP_ID • EMP_NAME • EMP_DESIGNATION And make EMP_ID as the primary key.
Create another table as DEPT_DETAILS with the fields as: • DEPT_ID • DEPT_NAME •
DEPT_LOCATION
Also create a table as PROJECTS with fields as: • P_ID • P_NAME Designate primary key
in both the fields.
Establish a relationship between the table EMP- DETAILS AND DEPT_DETAILS AS 1:1,
1: M and M: 1. Also enforce referential integrity constraint on it and write down the steps
for the same

ONE TO ONE RELATIONSHIP

ADITYA DAS 48 40221101718


Information System Management

ONE TO MANY RELATIONSHIP

ADITYA DAS 49 40221101718


Information System Management

MANY TO ONE

ADITYA DAS 50 40221101718


Information System Management

ADITYA DAS 51 40221101718


Information System Management

PRACTICAL-16
Q) Explain in brief about the query object in MSACCESS 2007. Write steps to execute
queries using the query wizard.
Create an ACCOUNT table with the following fields: •Acc no •Act type •Do_opening
•Transaction_type •Balance •Account H_name •Transaction ID
Enter 12 records in the table and perform the following queries on it.
 Display the acc no in ascending order.
 Display the details of account where acc no is 675.
 Display the details of where acc no is 675 and name is AJAY
 Display the acc no, acc type, account H_name and balance where balance is greater
than 5000.

SOLUTION: A query is a request for data results, and for action on data. You can use a query to answer a
simple question, to perform calculations, to combine data from different tables, or even to add, change, or
delete table data.
 As tables grow in size they can have hundreds of thousands of records,
which makes it impossible for the user to pick out specific records from
that table.
 With a query you can apply a filter to the table's data, so that you only get
the information that you want.
 Queries that you use to retrieve data from a table or to make calculations
are called select queries.
 Queries that add, change, or delete data are called action queries.
 You can also use a query to supply data for a form or report.
 In a well-designed database, the data that you want to present by using a
form or report is often located in several different tables.
Display the acc no in ascending order

ADITYA DAS 52 40221101718


Information System Management

ADITYA DAS 53 40221101718


Information System Management

Display the details of account where acc no is 675

ADITYA DAS 54 40221101718


Information System Management

Display the details of where acc no is 675 and name is AJAY

ADITYA DAS 55 40221101718


Information System Management

Display the acc no, acc type, account H_name and balance where balance is greater than 5000

ADITYA DAS 56 40221101718


Information System Management

ADITYA DAS 57 40221101718


Information System Management

PRACTICAL-17
Q) Create a table Student with following fields •Enrolment_no •S_name •Course_id •Batch
•Semester Execute the following queries after entering 10 records in the table.
 Display the list of Students in batch ‘2017-2020’
 Display the Enrolment_no of fourth semester students.
 Display the list of students of batch ‘2017-2020’ and course_is 17.
 Display the number of students in course_id 44.
SOLUTION
Display the list of Students in batch ‘2017-2020’

ADITYA DAS 58 40221101718


Information System Management

Display the Enrolment_no of fourth semester students.

ADITYA DAS 59 40221101718


Information System Management

Display the list of students of batch ‘2017-2020’ and course_is 17

ADITYA DAS 60 40221101718


Information System Management

Display the number of students in course_id 44

ADITYA DAS 61 40221101718


Information System Management

PRACTICAL-18
Q) Create the following table CUSTOMER having the
columns, data types.
Field Name Data Type
Customer_ID Number
Customer_Name Text
Designation Text
City Text
Country Text
Phone Number
Insert the data into table Customer. And apply the
queries:
 Display customer details having designation Sales Representative.
 Retrieve customerwho isliving in Canada.
 Show details of the customer whose name is Victoria.
 Showdetail ofthe customer who lives in Sweden.
 Show detail of the customer who is owner.

SOLUTION

Display customer details having designation Sales Representative.

ADITYA DAS 62 40221101718


Information System Management

Retrieve customer who is living in Canada

ADITYA DAS 63 40221101718


Information System Management

Show details of the customer whose name is Victoria

ADITYA DAS 64 40221101718


Information System Management

Show detail of the customer who lives in Sweden

ADITYA DAS 65 40221101718


Information System Management

Show detail of the customer who is owner

ADITYA DAS 66 40221101718


Information System Management

PRACTICAL – 19
Q) Create a table EMPLOYEE either the following fields: •Emp_id •Emp_name
•Dept_name •Salary •Add •Date of joining

Perform the following queries on it

1.Delete the records of the employee whose Emp_id is 101

2. Delete the record of the employees whose Dept_name is HR and salary >10000

3. Delete the record of the employee whose name begins with S or salary >10000

4. Update the record of the employees, set Dept_name = IT where Dept_name is


PRODUCTION.

5. Update the record of the employee, set salary to 15000 where Dept_name is IT.

SOLUTION

Delete the records of the employee whose Emp_id is 101

ADITYA DAS 67 40221101718


Information System Management

Delete the record of the employees whose Dept_name is HR and salary >10000

ADITYA DAS 68 40221101718


Information System Management

Delete the record of the employee whose name begins with S or salary >10000

ADITYA DAS 69 40221101718


Information System Management

Update the record of the employees, set Dept_name = IT where Dept_name is


PRODUCTION.

Update the record of the employee, set salary to 15000 where Dept_name is IT
ADITYA DAS 70 40221101718
Information System Management

ADITYA DAS 71 40221101718


Information System Management

PRACTICAL – 20
Q) Create a table named STUDENT_DETAILS with the following fields: • R_no • Name •
Course name • Attendance • Dob • Add Course will have values either economics or dbms.
Enter 5 records.
Create a form for the above table and add the following buttons to it:
 Go to first record
 Go to last record
 Go to previous record
 Go to next record

ADITYA DAS 72 40221101718


Information System Management

PRACTICAL – 21
Q) Discuss All DDL Commands with its syntax.
CREATE DATABASE
A Database is defined as a structured set of data. So, in SQL the very first step to store the data in a well
structured manner is to create a database. The CREATE DATABASE statement is used to create a new database
in SQL.

Syntax:
CREATE DATABASE database_name; database_name: name of the database.

CREATE TABLE
The CREATE TABLE statement is used to create a table in SQL. We know that a table comprises of rows and
columns. So while creating tables we have to provide all the information to SQL about the names of the columns,
type of data to be stored in columns, size of the data etc. Let us now dive into details on how to use CREATE
TABLE statement to create tables in SQL.

Syntax:
CREATE TABLE table_name
(column1 data_type(size),
column2 data_type(size),
column3 data_type(size),

DROP

It is used to delete a whole database or just a table.The DROP statement destroys the objects like an existing
database, table, index, or view. A DROP statement in SQL removes a component from a relational database
management system(RDBMS).

Syntax:

DROP TABLE table_name; table_name: Name of the table to be deleted.

DROP DATABASE database_name; database_name: Name of the database to be deleted.

TRUNCATE

TRUNCATE statement is a Data Definition Language (DDL) operation that is used to mark the extents of a table
for deallocation (empty for reuse). The result of this operation quickly removes all data from a table, typically
bypassing a number of integrity enforcing mechanisms. The TRUNCATE TABLE mytablestatement is logically
(though not physically) equivalent to the DELETE FROM mytable statement (without a WHERE clause).

Syntax:
ADITYA DAS 73 40221101718
Information System Management

TRUNCATE TABLE table_name; table_name: Name of the table to be truncated.

ALTER

Sometimes we may want to rename our table to give it a more relevant name. For this purpose we can use ALTER
TABLE to rename the name of table.

Syntax

ALTER TABLE table_name;

RENAME TO new_table_name;

ALTER TABLE Student RENAME COLUMN NAME TO FIRST_NAME;

ADITYA DAS 74 40221101718


Information System Management

PRACTICAL – 22
Q). Write SQL Queries using Data Definition Commands like CREATE, DROP, TRUNCATE, RENAME,
ALTER. Create Table named Student with Fields Student id, Name, Age, Course, Fees. And apply above
mentioned commands on the table.

CREATE

INSERT

ADITYA DAS 75 40221101718


Information System Management

OUTPUT

ALTER

ADITYA DAS 76 40221101718


Information System Management

RENAME

DROP

OUTPUT

DELETE
ADITYA DAS 77 40221101718
Information System Management

ADITYA DAS 78 40221101718


Information System Management

PRACTICAL – 23
Q) Write SQL Queries using Data Definition Commands Create Table named Employee
with Fields • EMP_ID
• EMP_NAME
• EMP_DESIGNATION
• EMP_DEPARTMENT
• EMP_CONTACT
And make EMP_ID as the primary key.
SOLUTION
CREATE

ADITYA DAS 79 40221101718


Information System Management

ADITYA DAS 80 40221101718


Information System Management

PRACTICAL-24
Q) Write SQL Queries using Data Definition Commands Create Table
named Employee with Fields
 EMP_ID
 EMP_NAME
 EMP_DESIGNATION
And make EMP_ID as the primary key.
Apply TRUNCATE, RENAME and ALTER commands.
SOLUTION
CREATE

ADITYA DAS 81 40221101718


Information System Management

ALTER

ADITYA DAS 82 40221101718


Information System Management

ADITYA DAS 83 40221101718


Information System Management

PRACTICAL-25
Q) Discuss All DML Commands with its syntax.

DML (Data Manipulation Language) : The SQL commands that deals with the manipulation of
data present in the database belong to DML or Data Manipulation Language and this includes most
of the SQL statements.

Commands of DML:

 INSERT – is used to insert data into a table.

 UPDATE – is used to update existing data within a table.

 DELETE – is used to delete records from a database table.

INSERT
The INSERT INTO statement of SQL is used to insert a new row in a table. There are two ways of
using INSERT INTO statement for inserting rows:
1. Only values: First method is to specify only the value of data to be inserted without the
column names.

Syntax:
INSERT INTO table_name VALUES (value1,
value2, value3,…); table_name: name of the table.

value1,names
2. Column value2,.. : value
and values both:ofInfirst column,
the second second
method column,…
we will specify bothfor
thethe new
columns
which we want to fill and their corresponding values as
shownbelow:

Syntax:
INSERT INTO table_name (column1, column2, column3,..) VALUES
( value1, value2, value3,..);

table_name: name of the table.

column1: name of first column, second column …

ADITYA DAS 84 40221101718


Information System Management

UPDATE
The UPDATE statement in SQL is used to update the data of an existing table in database. We can
update single columns as well as multiple columns using UPDATE statement as per our requirement.
Syntax:
UPDATE table_name SET column1 = value1,
column2 = value2,... WHERE condition;

table_name: name of the table


column1: name of first , second, third column....

DELETE
The DELETE Statement in SQL is used to delete existing records from a table. We can delete a
single record or multiple records depending on the condition we specify in the WHERE clause.
Syntax:

DELETE FROM table_name WHERE


some_condition; table_name: name of the
table

ADITYA DAS 85 40221101718


Information System Management

PRACTICAL -26
Q) Write SQL Queries using Data Manipulation Commands like INSERT, UPDATE,
DELETE and SELECT. Insert record into Table named Student with Fields Student id,
Name, Age, Course, Fees. And apply above mentioned commands on the table.
SOLUTION

INSERT

ADITYA DAS 86 40221101718


Information System Management

ADITYA DAS 87 40221101718


Information System Management

UPDATE

ADITYA DAS 88 40221101718


Information System Management

DELETE

ADITYA DAS 89 40221101718


Information System Management

SELECT

ADITYA DAS 90 40221101718


Information System Management

PRACTICAL-27
Q) Write SQL Queries using Data Manipulation Commands Insert record into Table
named Employee with Fields
• EMP_ID
• EMP_NAME
• EMP_DESIGNATION
• EMP_DEPARTMENT
• EMP_CONTACT
And make EMP_ID as the primary key. And apply above mentioned commands on the
table
CREATE

ADITYA DAS 91 40221101718


Information System Management

INSERT

PRACTICAL-28

Q) Define all aggregate functions with its work defined in SQL


SOLUTION

An aggregate function allows you to perform a calculation on a set of values to return a single
scalar value. We often use aggregate functions with the GROUP BY and HAVING clauses of the
SELECT statement.

The following are the most commonly used SQL aggregate functions:
ADITYA DAS 92 40221101718
Information System Management

AVG – calculates the average of a set of values.


COUNT – counts rows in a specified table or view.
MIN – gets the minimum value in a set of values.
MAX – gets the maximum value in a set of values.
SUM – calculates the sum of values.

Example:

Following table1 shows Id, name and salary columns:

SQL AGGREGATE FUNCTIONS:

1.COUNT function

ADITYA DAS 93 40221101718


Information System Management

ADITYA DAS 94 40221101718


Information System Management

2.AVG function

ADITYA DAS 95 40221101718


Information System Management

3.SUM function

ADITYA DAS 96 40221101718


Information System Management

4.MIN function

ADITYA DAS 97
40221101718
Information System Management

5.MAX function

ADITYA DAS 98 40221101718


Information System Management

PRACTICAL-29

Q) Write SQL Queries using Data Manipulation Commands Insert record into Table named
Employee with Fields • EMP_ID • EMP_NAME • EMP_DESIGNATION • EMP_AGE •
EMP_DEPARTMENT • EMP_SALARY And make EMP_ID as the primary key.

1. Write a query to find the salary of a person where age is <= 26 and salary >= 25000 from
Employee Table.

2. Write a query to find the name of Employee whose name is like “Ku%”.

3. Write a query to find the customer details using “IN” and “Between” operator where age
can be 25 or 27.

SOLUTION
Command:
CREATE TABLE EMPLOYEE
(EMP_ID NUMBER PRIMARY KEY,
EMP_NAME TEXT,
EMP_DESIGNATION TEXT,
EMP_AGE NUMBER,
EMP_DEPARTMENT TEXT,
EMP_SALARY CURRENCY);
Output

Command :
INSERT INTO EMPLOYEE VALUES (1001,"NAMAN","MANAGER",20,"HR",40000);

ADITYA DAS 99 40221101718


Information System Management

QUERY 1 :
SELECT EMP_SALARY FROM EMPLOYEE
WHERE EMP_AGE<=26 AND EMP_SALARY>=25000;

QUERY 2 :
SELECT EMP_NAME FROM EMPLOYEE
WHERE EMP_NAME LIKE 'KU*';

ADITYA DAS 100 40221101718


Information System Management

PRACTICAL -30
Q) Write SQL Queries using SQL Commands Create a Table Product with Fields •
PRO_ID • PRO_NAME • PRO_PRICE And make PRO_ID as the primary key.
Insert 10 Records into the Table.
1. Write a query to find the Name of Product where PRO_PRICE>= 500 from PRODUCT
Table.
2. Write a query to implement Aggregate Functions on field PRICE”.
3. Write a query to COUNT the number of Records in the Product Table.
SOLUTION
CREATE

ADITYA DAS 101 40221101718


Information System Management

INSERT

ADITYA DAS 102 40221101718


Information System Management

QUERY1

ADITYA DAS 103 40221101718


Information System Management

QUERY2

AVG

ADITYA DAS 104 40221101718


Information System Management

COUNT

ADITYA DAS 105 40221101718


Information System Management

SUM

ADITYA DAS 106 40221101718


Information System Management

MINIMUM

ADITYA DAS 107 40221101718


Information System Management

MAXIMUM

ADITYA DAS 108 40221101718


Information System Management

QUERY3

ADITYA DAS 109 40221101718


Information System Management

PRACTICAL-31
Q) Create an ER diagram for COLLEGE MANAGEMENT SYSTEM

Last
name Stud_num
First
name

Stude Take Admission


Ema admissi
il nt enroll
on me
nent
Addre
ss Course
Enrollme name
nt

Tim
Time e
table
Attribut Dat
es e

Teacher’s
name

am
Last name
e

First name
Sub
Subje code
Email Lecturer Lectur
es cts
Lecturer

Address Sub
unit

ADITYA DAS 110 40221101718


Information System Management

ADITYA DAS 111 40221101718


Information System Management

PRACTICAL-32
Q) Create an ER diagram for COLLEGE MANAGEMENT SYSTEM
Login id Login user

User login Role id


Username id
User Roles
Role name
Mobile Has

Address

Per id
Permission

Per name
Manage

Passpor
t
Id Pass
Airlines
P-id Passenger Reservatio
Date n
date
P _name

Type Type
Address has Passpor
t

Ticket
reservation Date

type
Book id

ADITYA DAS 112 40221101718


Information System Management

PRACTICAL-33
Q) Create an ER Diagram for Employee Management System

Login id Login users

User id Login Role id


Username

User Roles Role name


Mobile has

Address

Per Id
Permission

Per Name

Manage

Sal_id
Password
Statuss Salary
Em_Id Leaves
Employees datee
Leave from
Em_phn Sal_month
has
Leave
Address Emp account
Departmen
t

Dep_id Dep_date

NAMAN DHINGRA 113 06121101718


Information System Management

PRACTICAL-34
Q) Create an ER Diagram for Library Management System

Login id Login user

User id login Role id


Username
User Roles
Role name
Mobile Has

Address

Per id
Permission

Per name

Manage

Enrollment Members Address add_id


Address
Stud_id
Email
Student city

Name Name
has House no.
Email Phone no.

Book
s Book_issue
date
Book _ id

NAMAN DHINGRA 114 06121101718


Information System Management

115
NAMAN DHINGRA 06121101718

You might also like