Lakshay ISM 26
Lakshay ISM 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:
TABLE
1
2. UPDATE STUDENT SET NAME="G" WHERE NAME="F"
2
STEPS:
1. Create a table named as STUDENT and insert five records.
2. Go to create tab and choose QUERY DESIGN option.
3
PRACTICAL-27
Question: 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. Answer:
SQL Queries:
4
2. UPDATE Employee SET EMP_NAME="D" WHERE EMP_NAME="B"
5
PRACTICAL-28
Q. Define all the Aggregate Functions with their work defined in the SQL.
Solution: Aggregate functions are used to perform calculations on sets of values and return a
single value as a result. These functions operate on a group of rows and produce a single value for
that group. Here are some common aggregate functions in SQL and their brief descriptions:
1. COUNT FUNCTION: COUNT () is used to count the number of rows in a result set that meets a
specified condition. It can be used with the asterisk (*) to count all rows or with a specific column
to count non-null values in that column.
2. SUM FUNCTION: SUM () calculates the sum of all values in a numeric column.
3. AVG FUNCTION: AVG () computes the average (mean) of values in a numeric column.
5. STDDEV FUNCTION: STDEV () is used to calculate the standard deviation of a set of numeric
values within a specified column. The standard deviation is a statistical measure of the amount of
variation or dispersion in a dataset. It provides insight into how spread out the values are and how
much they deviate from the mean (average).
6. VARIANCE FUNCTION: The variance is a statistical measure that quantifies how data points
in a dataset differ from the mean (average) value. It is calculated as the average of the squared
differences between each data point and the mean.
6
PRACTICAL-29
Q- Write SQL Queries using Data Manipulation Commands and 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:
Step 1: First create a Table Name Student_Marks and enter the relevant entries.
7
Step2: Then Go to Create and Click Query Wizard.
Then select on open the query to open the information tab, then click on finish.
8
Then finally, go to the SQL View.
Step 3: For Query 1, “to find the salary of a person where age is <= 26 and salary >= 25000”,
write the query as shown below and then click on “RUN”.
Step 4: On running the query, the output will display the age of employees whose <= 26 and
salary >= 25000” .
Step 5: For Query 2, “to find the name of Employee whose name is like Ku%”, write the
query as shown below and then click on “RUN”.
9
Step 6: On running the query, the output will the name of Employee whose name is like Ku%”.
Step 7: For Query 3, “to find the customer details using “IN” and “Between” operator where
age can be 25 or 27”. write the query as shown below and then click on “RUN”.
Step 8: On running the query, the output will the details of employee whose age can be 25 or
27.
10
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 7 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 a table with fields mentioned above in question, using SQL commands.
Click on run and you can see that the table is created.
Click on run and you can see that the record has been entered.
11
Similarly, add other records as well by using Insert Command.
Write the mentioned query to get the names of those products whose price>=500.
Write the below mentioned query to Sum the Price of the products.
12
Click on run and you can see the results.
13
PRACTICAL-31
14
In the database tools tab, go to relations column.
15
In the dialogue box click on Create new.
A new dialogue box will open, in that box enter the table names and column names, between which we
want to establish relationships and click on ok.
Below is a simplified example that includes essential entities in a college management system:
Entities:
1. Student:
Attributes: Student_ID (Primary Key), Name, Contact, DOB.
2. Course:
Attributes: Course_ID (Primary Key), Course Name.
3. Faculty:
Attributes: Faculty_ID (Primary Key), Name, Subject.
4. Department:
16
Attributes: Department_ID (Primary Key), Department Name.
17
Relationships and Cardinality
Cardinality Notation: Many Students (M) can enrol in Single (1) Course.
Explanation: A student can enrol in single course, but a course can have multiple
students enrolled in it.
Cardinality Notation: Many Faculty members (M) can be associated with (1) Department.
Explanation: Many faculty members can belong to a single department, but each
faculty member is associated with at most one department.
18
PRACTICAL-32
Q. Create an ER diagram for an Airline Reservation System.
The EntityRelationship (ER) diagram for an airline reservation system is a visual representation
of the data model that describes the structure of the system and the relationships between
different entities. Here's a brief explanation of the key elements:
1. Entities:
Passenger Entity: Represents individuals who use the reservation system. It contains
attributes like PassengerID (unique identifier), Name, and ContactNumber.
Flight Entity: Represents a scheduled flight. It has attributes like FlightID (unique
identifier), Airline, Departure Time, Arrival Time, Desto
Airport Entity- It represents where flight land.
Booking Office- Represents Place where the ticket for the fight has been booked.
19
2. Attributes:
4. Primary keys
Primary Keys: Unique identifiers for each entity (e.g., PassengerID, Office_ID,
Flight_no, Booking_No, Booking_no., Code).
20
PRACTICAL-33
Q. Create an ER diagram for an Employee Management System.
21
Relationships And Cardinality
1. Employee - Department Relationship:
One-to-Many relationship from Department to Employee.
Each department can have many employees, but each employee belongs to only one department.
Cardinality: (1:M) - One department to Many employees.
101
PRACTICAL-34
Q-Create an ER Diagram for Library Management system
102
Above is an Entity-Relationship Diagram (ERD) for a Library Management System
with four entities:
1. Member Entity (Attributes):
MemberID (Primary Key)
Name
2. Login Entity (Attributes):
Login_ID (Primary Key)
Login_Password
Book_ID(Primary Key)
Book_Name
Book_Author
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103
103