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

DBMS

The document describes tables and queries related to a company's projects, departments, and employees. It includes sample data and queries to retrieve information like employee details for a specific department, names of employees starting with a letter, and minimum/maximum salaries by department.

Uploaded by

Aditya More
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)
10 views

DBMS

The document describes tables and queries related to a company's projects, departments, and employees. It includes sample data and queries to retrieve information like employee details for a specific department, names of employees starting with a letter, and minimum/maximum salaries by department.

Uploaded by

Aditya More
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/ 2

Practical 04

Tables:
1) Project:(pid(foreign_key),pname,pDescription,pCategory)
2) Department:(did,pid(foreign_key),dname(primary_key))
3) Employee:e(eid(primary),ename,salary,did,pid(foreign),dname(foreign))

1)select * from project;


+-----+--------------+---------------+--------------+
| pid | project_desc | project_categ | project_name |
+-----+--------------+---------------+--------------+
| 11 | AI_based | software | XYZ |
| 22 | ML_based | hardware | ABC |
| 33 | DSA_based | CAD | PQR |
| 44 | CLOUD_based | software | MNP |

2) select * from department;


+------+------+------------+
| did | pid | dept_name |
+------+------+------------+
| 44 | 44 | Production |
| 11 | 11 | AI |
| 22 | 22 | CS |
| 33 | 33 | IT |

3) select * from employee;


+-----+-------+--------+------+------+------------+
| eid | ename | salary | did | pid | dept_name |
+-----+-------+--------+------+------+------------+
| 101 | Maddy | 20000 | 22 | 22 | AI |
| 102 | sandy | 30000 | 33 | 33 | Production |
| 103 | Candy | 40000 | 44 | 44 | CS |
| 104 | Andy | 50000 | 11 | 11 | IT |

Query 1] Display details of emp working on production dept


select ename,salary,did,pid from employee where dept_name='Production';
+-------+--------+------+------+
| ename | salary | did | pid |
+-------+--------+------+------+
| sandy | 30000 | 33 | 33 |
+-------+--------+------+------+
Query 2]Display details of emp;
Ans: select * from employee;
Query 3]Display name of emp whose start letter is ‘a’
select ename from employee where ename like 'a%';
+-------+
| ename |
+-------+
| Andy |
Query 4]arrange the name of project employee department in alphabetical order
select project_name,ename,dept_name from project join employee on
project.pid=employee.pid order by project_name,ename,dept_name;
+--------------+-------+------------+
| project_name | ename | dept_name |
+--------------+-------+------------+
| ABC | Maddy | AI |
| MNP | Candy | CS |
| PQR | sandy | Production |
| XYZ | Andy | IT |

Query 5]display name of employee who are not working for production
department and whose department ID is 44
select ename from employee where did=44 or dept_name!='Production';
+-------+
| ename |
+-------+
| Maddy |
| Candy |
| Andy |

Query 6]list of project where employee working on XYZ project


select * from project where project_name='XYZ';
+-----+--------------+---------------+--------------+
| pid | project_desc | project_categ | project_name |
+-----+--------------+---------------+--------------+
| 11 | AI_based | software | XYZ |

Query 7] list of employee with minimum , maximum salary according to


department name
select dept_name,min(salary),max(salary) from employee group by dept_name;
+------------+-------------+-------------+
| dept_name | min(salary) | max(salary) |
+------------+-------------+-------------+
| AI | 20000 | 20000 |
| CS | 40000 | 40000 |
| IT | 50000 | 50000 |
| Production | 30000 | 30000 |

Query 8]display project name whose category belonging in either hardware or


software
select project_name from project where project_categ='hardware' or project_categ=
'software';
+--------------+
| project_name |
+--------------+
| XYZ |
| ABC |
| MNP |

You might also like