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

ISM file

The document provides SQL commands for creating and managing student and employee information tables, including inserting data and querying specific information such as salaries and departments. It also covers updating records and modifying table structures, along with examples of using SQL functions like COUNT and MAX. Additionally, it mentions the creation of ER diagrams for hospital and examination management systems.

Uploaded by

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

ISM file

The document provides SQL commands for creating and managing student and employee information tables, including inserting data and querying specific information such as salaries and departments. It also covers updating records and modifying table structures, along with examples of using SQL functions like COUNT and MAX. Additionally, it mentions the creation of ER diagrams for hospital and examination management systems.

Uploaded by

yaminijawlia22
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Ques 1: Create Student Table.

Syntax:
create table student(std_id int, name varchar(30), email varchar(50), phone_number varchar(10));
insert into student value(1, "shubham", "[email protected]", 9813470000);
insert into student value(2, "anshul", "[email protected]", 8463182345);
insert into student value(3, "shashu", "[email protected]", 9845684444);
insert into student value(4, "agrim", "[email protected]", 7510022222);
insert into student value(5, "aryan", "[email protected]", 8512032222);
select*from student

1
Ques 2: Create Employee information table.

Creating a basic table involves naming the table and defining its columns and each column’s data type:

QUERY: For creating students table the following command is:


Create table emp(id int,name varchar (20),email
Varchar(30),salaryint(10),department varchar(20));

INSERT VALUE IN TABLE:

Create table emp_inf (id int(10),name varchar(20),email varchar(30),salary int(10), dept


varchar(30),city varchar(30) );
insert into emp_inf values(1,'Aryan','[email protected]',100000,'HR','Delhi');
insert into emp_inf values(2,'Anika','[email protected]',80000,'sales','Uttar Pradesh');
insert into emp_inf values(3,'Aakash','[email protected]',150000,'finance','Mumbai');
insert into emp_inf values(4,'Dhawar','[email protected]',180000,'CA','Delhi');
insert into emp_inf values(5,'Deergha','[email protected]',150000,'sales','Pune');
insert into emp_inf values(6,'Ishan','[email protected]',50000,'Marketing','Kolkata');
insert into emp_inf values(7,'July','[email protected]',70000,'IT','Nagpur');
insert into emp_inf values(8,'Himani','[email protected]',170000,'CA','Pune');
insert into emp_inf values(9,'Rakesh','[email protected]',150000,'graphic','Uttar Pradesh');
insert into emp_inf values(10,'Sara Atray','[email protected]',90000,'CA','Delhi');
insert into emp_inf values(11,'Tina','[email protected]',80000,'finance','Delhi');
insert into emp_inf values(12,'Varsha','[email protected]',100000,'HR','Mumbai');
insert into emp_inf values(13,'Vansh','[email protected]',70000,'graphic','Ahmedabad');
insert into emp_inf values(14,'Yash','[email protected]',50000,'IT','Mumbai');

2
OUTPUT:

3
Ques 3: Display the salary of all employees from Employee Information
table.

create table emp_info(emp_id int, name varchar(20), email varchar(50), hire_date int, salary int,
department varchar(20), city varchar(20));

QUERY
insert into emp_info value(1001, "kunal", "[email protected]", 2012-05-01, 25000, "HR", "Delhi");
insert into emp_info value(1002, "ramesh", "[email protected]", 2022-05-01, 30000, "Sales",
"Mumbai");
insert into emp_info value(1003, "priyanshu", "[email protected]", 2022-01-01, 50000,
"Finance", "Agra");
insert into emp_info value(1004, "khwab", "[email protected]", 2023-01-01, 40000, "HR", "Delhi");
insert into emp_info value(1005, "rishi", "[email protected]", 2011-07-01, 70000, "Finance",
"Hyderabad");
Select Salary from employee Information.

OUTPUT:

4
Ques 4: Display the different department in the company from Employee
Information.

create table emp_info(emp_id int, name varchar(20), email varchar(50), hire_date int, salary int,
department varchar(20), city varchar(20));

insert into emp_info value(1001, "kunal", "[email protected]", 2012-05-01, 25000, "HR", "Delhi");

insert into emp_info value(1002, "ramesh", "[email protected]", 2022-05-01, 30000, "Sales",


"Mumbai");

insert into emp_info value(1003, "priyanshu", "[email protected]", 2022-01-01, 50000,


"Finance", "Agra");

insert into emp_info value(1004, "khwab", "[email protected]", 2023-01-01, 40000, "HR",


"Delhi");

insert into emp_info value(1005, "rishi", "[email protected]", 2011-07-01, 70000, "Finance",


"Hyderabad");

select department from emp_info;

OUTPUT:

5
Ques 5. Display total number of departments in the company from Employee
Information table.

First, we have to display the table where all the records are entered for the following command is: -
select * from Emp_info; The table will execute with the fields you have entered.

Here we will use an aggregate function: - COUNT () It returns the number of rows in a table. It allows you
to count all rows or only rows that match a specified condition.

Syntax: Select Count(column_name) from table_name;


QUERY: Select Count(emp_dept) from emp_info;

INSERT VALUE IN TABLE:

Select first_name, age From Customers;


Select count (Emp_Dept) from Emp_int;

OUTPUT:

6
Ques 6: Display the name of employees whose name starts with ‘a’.

Under this LIKE operator is used to search for a specified pattern in a columnthereare 2 wildcards often
used in conjunction with the like operator: %,

% represents zero or more characters_represents a single character.

We also used WHERE clause in the command. WHERE clause allows you to specify search condition
for the rows returned by the query WHERE clause select statement is to filter rows from the result set.

SYNTAX: select column1, column2 from table_name where condition;

QUERY: select emp_name from emp_where emp_name like'A%'; INSERT

VALUE IN TABLE:

SELECT first-name, age from customers;

Select Emp_Name from Emp_info where Emp_Name like ‘A%’;

OUTPUT:

7
Ques 7 . Display the name of those employees whose second alphabet is ‘a’.

Under this Like operator is used to search for a specified pattern in a colums. There are 2 wildcards ofter
used in conjunction with the like operator: %,_%: Represents zero or more characters._: Represents a single
character.

We have also used Where clause in this command. Where clause allows you tospecify a
search condition for the rows returned by a query. Where clause in select statement is to
filter rows from the result set.

Syntax: Select column1,column2,..from table_name where condition;

Query: Select emp_name from emp_info where emp_name like ‘_a%’;

INSERT VALUE IN TABLE:

Select First_name,age From Customers;


Select emp_name from emp_info where emp_name like'_A%';

OUTPUT:

8
Ques 8 . Display Id and name of those employees who lives in Delhi.

Under this command WHERE clause allows you to specify a search condition for the rows returned by
the query WHERE clause select statement is to filter rows from the result set.

QUERY: Select EMP_ ID, NAME FROM EMP WHERE CITY=”DELHI”

It will display the ID and Name of those who live in Delhi only INSERT

VALUE IN TABLE:

SELECT first_name, age


From Customers;
Select Emp_Id,Emp_city from Emp_inf where Emp_city like ‘DELHI’;

OUTPUT:

9
Ques 9. Display Id and name of those employees who lives in Delhi/Mumbai.

Under this Where clause allows you to specify a search condition for the rows returned by aquery.
Where clause in select statement is to filter rows from the resultset. We have also used Or operator
which displays a record if any of the conditions separated by Or is True.

Syntax: Select column1, column 2,.. From table_name where condition 1 or condition 2 or
condition 3. ;

Query: Select emp_id, emp_name from emp_info where emp_city=”Delhi” or emp_city=”Mumbai”;

OUTPUT:

10
Ques 10. Display name & maximum salary in each department of company

Under this Where clause allows you to specify a search condition for the rows
returned by a query. Where clause in select statement is to filter rowsfrom the
result set.

Apart from that MAX () function is also used. It is an aggregate function that returns the
maximum value from an expression.

Syntax: MAX( DISTINCT expression)


Query: Select emp_name, emp_dept from emp_info where emp_salary=(select
max(emp_salary) from emp_info);
INSERT VALUE IN TABLE:
Select first_name, agr from customers;
Select Emp_dept,Emp_name from Emp_inf where Emp_salary =(select max(Emp_Salary) from
(emp_inf);

OUTPUT:

11
Ques 11 . Add phone no. column in employee information table.

Here ALTER command is used. It helps to modify an existing database and table. The ALTER
command is used. It helps to modify an existing database and table. The ALTER statement is used
to “ADD”, “DROP” and “MODIFY” the existing table.

ADD Column: To add column in a table.

Syntax (to add a column): ALTER table table_name ADD column_name, datatype;

Query: Alter table emp_info add emp_PhoneNo int(10);

INSERT VALUE IN TABLE:

SELECT first_name, age From customers;


Create table emp_inf (id int(10),name varchar(20),phoneno int(10),salary int(10), dept
varchar(30),city varchar(30) );
insert into emp_inf values(1,'Aryan',9856729900,100000,'HR','Delhi');
insert into emp_inf values(2,'Anika',’ ‘ ,80000,'sales','Uttar Pradesh');
insert into emp_inf values(3,'Aakash', ',150000,'finance','Mumbai');
insert into emp_inf values(4,'Dhawar', ',180000,'CA','Delhi');
insert into emp_inf values(5,'Deergha', ',150000,'sales','Pune');
insert into emp_inf values(6,'Ishan', ',50000,'Marketing','Kolkata');
insert into emp_inf values(7,'July', ',70000,'IT','Nagpur');
insert into emp_inf values(8,'Himani', ',170000,'CA','Pune');
insert into emp_inf values(9,'Rakesh', ',150000,'graphic','Uttar Pradesh');
insert into emp_inf values(10,'Sara Atray', ',90000,'CA','Delhi');
insert into emp_inf values(11,'Tina', ',80000,'finance','Delhi');
insert into emp_inf values(12,'Varsha', ',100000,'HR','Mumbai');
insert into emp_inf values(13,'Vansh', ',70000,'graphic','Ahmedabad');
insert into emp_inf values(14,'Yash',’ ',50000,'IT','Mumbai');
alter table Emp_inf add PhoneNo int(10);

12
OUTPUT:

13
Ques 12. Update the city of Ms. Sara Atray from Delhi to Uttar Pradesh

Here UPDATE statement is used. It helps to modify existing data in a table. Update statement
change values in one or more columns of a single row or multiple rows.

Syntax: UPDATE table_name set column1= value where some_column= some_value.

Query: Update emp_info set emp_city= “Uttar Pradesh” where emp_name= “SaraAtray”;

INSERT VALUE IN TABLE:

Update Emp_inf set Emp_City=’Uttar Pradesh’ where Emp_Name= ‘Sara Atray’);Updated

statement will change the city of sara from Delhi to Uttar Pradesh:

OUTPUT:

14
Ques 13. Make ER-Diagram of Hospital Management System.

Since hospitals are health care providers, thus they need to have efficient management. A hospital
management system ensures that information regarding health care is managed properly.
Furthermore, it also aids in the job completion of health care providers.

So, people use ER diagrams to design their hospital management systems. These ER diagrams
help them to visualize all the database tables and identify the relationships between different
entities and their attributes.

To better understand an ER diagram, we will discuss a few examples about ER diagram for hospital
management systems.

15
Ques 14. Make E-R Diagram of Examination System.

16

You might also like