Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Assignment
You have the following table Employee write a SQL commands for all question below :
1. Get all employee details from the employee table order by First_Name descending
Select * from employee order by FIRST_NAME desc;
1. Get employee details from employee table whose employee name is “John”
2. Select * from employee order by FIRST_NAME='john';
1. Get employee details from employee table whose employee name are “John” and “Roy”
1. Get employee details from employee table whose first name starts with 'J'
Select * from employee order by FIRST_NAME like 'J%';
1. Get employee details from employee table whose first name ends with 'n'
Select * from employee order by FIRST_NAME like 'N%';
1. Get employee details from employee table whose Salary greater than 600000
Select * from employee where salary >600000;
1. Get employee details from employee table whose Salary less than 800000
2. Select * from employee where salary >800000;
1. Get employee details from employee table whose Salary between 500000 and 800000
2. Select * from employee where salary between 500000 and 800000;
1. Get department ,total salary from employee table.
Selct employee ,sum(salary) from employee;
Assignment (Chapter 3)
Find Candidate keys , Primary Key , Unique Keys for the following tables :
111 Maths 38
111 Physics 38
222 Biology 38
333 Physics 40
333 Chemistry 40
F.K F.K
F.K
F.K F.K
Name:Ali Bajawi ID number :201609284
2. Draw a relational schema diagram specifying the foreign keys for this schema.
F.K
F.K
F.K
3. Draw a relational schema diagram specifying the foreign keys for this schema.
F.K
F.K
F.K
F.K
Name:Ali Bajawi ID number :201609284
4. Draw a relational schema diagram specifying the foreign keys for this schema.
F.K
F.K F.K
5. Draw a relational schema diagram specifying the foreign keys for this schema.
F.K F.K
F.K F.K
6.Draw a relational schema diagram specifying the foreign keys for this schema.
Name:Ali Bajawi ID number :201609284
F.K
F.K F.K
F.K
7. Draw a relational schema diagram specifying the foreign keys for this schema.
F.K
F.K F.K
Assignment (Chapter 4)
Name:Ali Bajawi ID number :201609284
For the following binary relationships, suggest cardinality ratios based on the common- sense meaning of the entity
types.
1. Design an ER schema for this application, and draw an ER diagram for the schema. Specify key
attributes of each entity type, and structural constraints on each relationship type. Note any
unspecified requirements, and make appropriate assumptions to make the specification
complete.
The library contains books which are described by an ISBN, Title, Specialization. Each Book is
published by one Publisher and written by many Authors.
An author is described by name, ID, Address, Fax and Phone number. Each author writes many
books.
A borrower is described by Card Number, Name, Address. It is required to keep track of date
out and due date of each borrowing transaction.
It is required to keep track of date out and due date of each borrowing transaction.
Name:Ali Bajawi ID number :201609284
2.Design an ER schema for this application, and draw an ER diagram for the schema. Specify key
attributes of each entity type, and structural constraints on each relationship type. Note any
unspecified requirements, and make appropriate assumptions to make the specification complete.
Each Doctor is described by Doc ID, Phone, address, and specialization. Each doctor is allowed
to work in only one department.
Each department is described by Dept no, Name, No of doctors and is supervised by a doctor.
Each patient is described by Card number, name, address, and phone. Each patient is assigned
to one or more department. It’s required to keep track each admission date.
Each lab is described by LabNo, name. It’s required to keep track any lab service that may be
done to the patient.
Name:Ali Bajawi ID number :201609284
3. Design an ER schema for this application, and draw an ER diagram for the schema. Specify key
attributes of each entity type, and structural constraints on each relationship type. Note any
unspecified requirements, and make appropriate assumptions to make the specification complete.
Each customer has associated with it zero to any number of recorded accidents.
Assignment (Chapter 6)
Topic(isbn, subject)
Branch(libname, city)
c. Give the title of each book on the topic of either alcohol or drugs.
σ (subject='alcohol'or subject= 'drugs')Book
d. Give the title and author of each book of which at least two copies are held in a branch located in Melbourne.
Authorname σ(quantity>=2 AND city='Melbourn') BOOK INSTOCK
e. Give the name of each Italian author who wrote an autobiography.
σ (subject=authomame AND citizenship='litaly')Author Book
Cod(courses)
b. List the marks of student who has name=’Ali’
Marks(Ali)
Name(jazan)
student(id, name)
enrolledIn(id, code)
subject(code, lecturer)
Code(subject)
g. What are the names of all the students?
Name(student)
h. What are the names of all the students in cs1500?
Assignment (Chapter 7)
1. Consider the relation Reg is in 1NF. Decompose the given relation into 2NF and 3NF with its
functional dependencies
Table : Reg
Table : Users
Name:Ali Bajawi ID number :201609284
3. Consider the relation STCO is in 1NF. Decompose the given relation into 2NF and 3NF with its
functional dependencies
Table : STCO
Stid St_name Address C_code Cname Hours T_id Tname T_dept Grade
Use above relation EMPLOYEE and write the relational algebra query for the following
:
Use above relation EMPLOYEE and write the relational algebra query.
List First name, Last name and salary of all employees who work in department number 5.
Name:Ali Bajawi ID number :201609284