Dbms 3
Dbms 3
Database changed
mysql> SHOW TABLES;
+-------------------+
| Tables_in_TE_B_15 |
+-------------------+
| Dependant |
| Dept |
| Employees |
| Project |
| Works |
| branch |
| customer |
| loan |
| stud1 |
| student |
+-------------------+
10 rows in set (0.00 sec)
mysql> Alter table Works add constraint Foreign Key (Projectid) references
Project(Projectid);
Query OK, 2 rows affected (0.76 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql>
mysql> select * from Dept;
+--------+-------------+------------+--------------+
| Deptno | Name | Location | Managerempid |
+--------+-------------+------------+--------------+
| 1 | Development | Building 1 | 111 |
| 2 | Testing | Building 1 | 112 |
| 3 | Planning | Building 2 | 113 |
| 4 | Planning | Building 2 | 114 |
+--------+-------------+------------+--------------+
4 rows in set (0.00 sec)
mysql> ^C
mysql> SELECT e.Name, e.city
-> FROM Employees e
-> JOIN Works w ON e.empid = w.empid
-> JOIN Project p ON w.Projectid = p.Projectid
-> WHERE p.title='Banking Project';
+----------+--------+
| Name | city |
+----------+--------+
| Shraddha | Nashik |
+----------+--------+
1 row in set (0.00 sec)
mysql>