SQL Assignment Day Practice
SQL Assignment Day Practice
===================================================================================
=========================================================================
create Table Faculty
(FacultyID int, Name varchar(18), Department varchar(5), Gender varchar(1), Salary
int, Working_hours int);
+-----------+---------+--------------------------------+--------+--------
+---------------+
| facultyid | name | department | gender | salary |
working_hours |
+-----------+---------+--------------------------------+--------+--------
+---------------+
| 1 | Aakash | Computer Science | M | 50000 |
45 |
| 1 | Sahil | NULL | M | 25000 |
50 |
| 2 | John | Humanities and Social Sciences | M | 100000 |
60 |
| 3 | Shelley | Computer Science | F | 75000 |
80 |
| 4 | Anannya | Computer Science | F | 45000 |
100 |
| 5 | Sia | Humanities and Social Sciences | F | 60000 |
40 |
+-----------+---------+--------------------------------+--------+--------
+---------------+
===================================================================================
========================================================================
Problem-2;
--------------
mysql> select facultyid, name,case when working_hours <=50 then 'not allowed' when
working_hours <= 80 then 20 when working_hours <= 120 then 40 end as
vacationhours from faculty;
+-----------+---------+---------------+
| facultyid | name | vacationhours |
+-----------+---------+---------------+
| 1 | Aakash | not allowed |
| 1 | Sahil | not allowed |
| 2 | John | 20 |
| 3 | Shelley | 20 |
| 4 | Anannya | 40 |
| 5 | Sia | not allowed |
+-----------+---------+---------------+
6 rows in set (0.00 sec)
===================================================================================
====================================================================
problem -3:
#Candidate key :
--------------------
#Prime Attributes :
Attributes of the database tables which are candidate keys of the database tables
are called prime attributes.
#Non-Prime attributes:
Attributes of the database tables which do not exist in any of the possible
candidate keys of the database tables are called non-prime attributes.
===================================================================================
====================================================================
Problem-4
------------------
create table
students(student_id int primary key,name varchar(12),address varchar(12));
===================================================================================
=========================================================================