20BCS030 - Mateen Khan - Dbms p9
20BCS030 - Mateen Khan - Dbms p9
mysql> CREATE TABLE STUDENT(S_num int not null auto_increment primary key,S_name
varchar(20) not null,Major varchar(10) not null,Level varchar(15) not null,Age int not null);
Query OK, 0 rows affected (0.08 sec)
mysql> show tables;
+-------------------+
| Tables_in_student |
+-------------------+
| student |
+-------------------+
1 row in set (0.01 sec)
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> create table Enrolled(snum int, cname varchar(20));
Query OK, 0 rows affected (0.09 sec)
mysql> create table Faculty(fid int primary key, fname varchar(20), deptid int);
Query OK, 0 rows affected (0.08 sec)
mysql> SHOW TABLES;
+-------------------+
| Tables_in_student |
+-------------------+
| class |
| enrolled |
| faculty |
| student |
+-------------------+
4 rows in set (0.01 sec)
mysql>
mysql> insert into Faculty values(201,'John', 301);
Query OK, 1 row affected (0.02 sec)
Q 9 For each faculty member that has taught class only in room R128 print the
faculty member’s name and the total number of classes he or she has taught.
Q 8 For all levels except JR, print the level and the average age of students for
that level.
Q 7 For each level, print the level and the average age of students for that level.
Q 6 Find the names of faculty members for whom the combined enrollment of
the course that they teach is less than five.
Q 5 Find the names of faculty members who teach in every room in which some
class is taught.
Q 4 Find the names of all students who are enrolled in two-class that meet at
the same time.
Q 3 Find the names of all classes that either meet in room R128 or have five or
more students enrolled.