0% found this document useful (0 votes)
35 views51 pages

Lakshay ISM 26

Uploaded by

masev35300
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views51 pages

Lakshay ISM 26

Uploaded by

masev35300
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 51

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:
TABLE

1. INSERT INTO STUDENT VALUES (106, "F", 16, "BCA", 150000)

1
2. UPDATE STUDENT SET NAME="G" WHERE NAME="F"

3. DELETE FROM STUDENT WHERE COURSE="BCA"

4. SELECT * FROM STUDENT WHERE NAME="A"

2
STEPS:
1. Create a table named as STUDENT and insert five records.
2. Go to create tab and choose QUERY DESIGN option.

3. Right click and choose SQL view option.

4. Type queries one by one.

5. In query tools, click on RUN option to see the output.

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:

Employee Table with Fields

SQL Queries:

1. INSERT INTO Employee VALUES (101, "A", “CEO”, "MGMT", 9863258747)

4
2. UPDATE Employee SET EMP_NAME="D" WHERE EMP_NAME="B"

3. DELETE FROM Employee WHERE EMP_NAME="C"

4. SELECT * FROM Employee WHERE EMP_NAME="A"

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.

Syntax: SELECT COUNT (*) FROM employees

2. SUM FUNCTION: SUM () calculates the sum of all values in a numeric column.

Syntax: SELECT SUM (salary) FROM employees

3. AVG FUNCTION: AVG () computes the average (mean) of values in a numeric column.

Syntax: SELECT AVG (salary) FROM employees

4. MAX FUNCTION: MAX () returns the maximum value from a column.

Syntax: SELECT MAX (salary) FROM employees

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).

Syntax: SELECT STDDEV (salary) FROM employees

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.

Syntax: SELECT VARIANCE (salary) FROM employees

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.

 Select “Simple Query Wizard” and Press OK.

 Click on Double Angular Brackets to transfer fields, Then Click on Next.

 Then select on open the query to open the information tab, then click on finish.

8
 Then finally, go to the SQL View.

 Then finally you will see this window on your screen.

 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.

 Write the mentioned query to insert the records.

 Click on run and you can see that the record has been entered.

11
 Similarly, add other records as well by using Insert Command.

 Go to design view and make Pro_ID Primary Key.

 Write the mentioned query to get the names of those products whose price>=500.

 Click on run and you can see the results.

 Write the below mentioned query to Sum the Price of the products.

12
 Click on run and you can see the results.

 Write the below mentioned query to count the no. of records.

 Click on run and you can see the results.

13
PRACTICAL-31

Q. Create an ER diagram for a College Management System.

Ques: Create an ER diagram for college management system.


Creating a complete ER (Entity-Relationship) diagram for a college management system involves
various entities and their relationships.
STEPS:
Create tables with the entity names and enter fields and records.

14
In the database tools tab, go to relations column.

In the dialogue box, add tables one by one.

Then in the relationship tools, choose edit relationships option.

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

1. Student to Faculty Relationship (M to m):

 Cardinality Notation: Many Students (M) can be Taught by (M) Faculty.


 Explanation: A student can have multiple faculty advisors (for different courses or
academic matters), and a faculty member can advise multiple students.

2. Student to Course Relationship (M to 1):

 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.

3. Faculty to Department Relationship (M to 1):

 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:

 Passenger Attributes: PassengerID, Name, Contact, Age..


 Flight Attributes: Flight_no, Airline, Departure_Time, Arrival_Time, Destination.
 Booking Office- Office_Id, Booking_No, Office_Name.
 Airport- Name, Code, City.

3. Relationships and Cardinalities:

 Passenger-Office Relationship (Many to 1): A passenger can have multiple


reservations, but each reservation is associated with one passenger.
 Booking Office-Flight Relationship (Many to 1): Each Flight can have multiple or
many booking offices.
 Flight-Airport Relationship (Many to 1) - Many Flights can land on a single airport.

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.

Above is an Entity-Relationship Diagram (ERD) for an Employee Management System with


four entities: Employee, Department, Role, and Project.
1. Employee Entity (Attributes):
 EmployeeID (Primary Key)
 Name
 Contact
 Address
2. Department Entity (Attributes):
 Department_ID (Primary Key)
 Department_Name

3. Roles Entity (Attributes):

 Role_Code (Primary Key)


 Role_Type

4. Project Entity (Attributes):

 Project ID (Primary Key)


 Start Date
 End Date

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.

2. Employee - Role Relationship:


Many-to-Many relationship from Role to Employee.
Each role can be assigned to many employees and each employee can have multiple roles..
Cardinality: (M:M) - Many employees to Many role.

3. Employee - Project Relationship:


Many-to-Many relationship between Employee and Project.
An employee can be assigned to multiple projects, and a project can have multiple employees.
Introduce a junction table (e.g., Employee Project Assignment) to represent this relationship.

Cardinality: (M:M) - Many employees to Many projects.

4. Department - Project Relationship:


One-to-Many relationship from Department to Project.
Each department can be associated with many projects, but each project belongs to only
one department.
Cardinality: (1:M) - One department to Many projects.

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

3. Roles Entity (Attributes):

 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

You might also like