0% found this document useful (0 votes)
6 views3 pages

Up_Lab3

Uploaded by

omimagamal31
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)
6 views3 pages

Up_Lab3

Uploaded by

omimagamal31
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/ 3

SQLServer Lab

Part 1:

1. Create the following tables with all the required information and load
the required data as specified in each table using insert statements
[at least two rows]

Tablename Details Comments


Department DeptNo (PK) DeptName Location 1-Create it by code
2-create default value =NY on
d1 Research NY Location Column
d2 Accounting DS
3-create a rule for this
d3 Markiting KW Datatype :values in
(NY,DS,KW)) and associate it
to the location column

Employee EmpNo Emp Emp Dept Salary 1-Create it by code


(PK) Fname Lname No 2-PK constraint on EmpNo
3-FK constraint on DeptNo
25348 Mathew Smith d3 2500
4-Unique constraint on Salary
10102 Ann Jones d3 3000
5-EmpFname, EmpLname
18316 John Barrimore d1 2400
don’t accept null values
29346 James James d2 2800 6-Create a rule on Salary
9031 Lisa Bertoni d2 4000 column to ensure that it is
2581 Elisa Hansel d2 3600 less than 6000
28559 Sybl Moser d1 2900

Project ProjectNo ProjectName Budget 1-Create it using wizard


(PK) 2-ProjectName can't contain
p1 Apollo 120000 null values
p2 Gemini 95000 3-Budget allow null
p3 Mercury 185600
Works_on EmpNo ProjectNo Job Enter_Date 1-Create it using wizard
(PK) (PK) EmpNo INTEGER -2
10102 p1 Analyst 2006.10.1 NOT NULL
10102 p3 Manager 2012.1.1 3-ProjectNo doesn't accept
25348 p2 Clerk 2007.2.15 null values
4-Job can accept null
18316 p2 NULL 2007.6.1 5-Enter_Date can’t accept null
29346 p2 NULL 2006.12.15 and has the current system
2581 p3 Analyst 2007.10.15 date as a default
9031 p1 Manager 2007.4.15 value[visually]
28559 p1 NULL 2007.8.1 6-The primary key will be
28559 p2 Clerk 2012.2.1 EmpNo,ProjectNo)
9031 p3 Clerk 2006.11.15 7-there is a relation between
29346 p1 Clerk 2007.1.4 works_on and employee,
Project tables
Testing 1-Add new employee with EmpNo =11111 In the works_on table [what will
Referential happen]
Integrity 2-Change the employee number 10102 to 11111 in the works on table [what will
happen]
3-Modify the employee number 10102 in the employee table to 22222. [what will
happen]
4-Delete the employee with id 10102
Table 1-Add TelephoneNumber column to the employee table[programmatically]
modification 2-drop this column[programmatically]
3-Bulid A diagram to show Relations between tables

2. Create the following schema and transfer the following tables to it


a. Company Schema
i. Department table (Programmatically)
ii. Project table (using wizard)
b. Human Resource Schema
i. Employee table (Programmatically)

3. Write query to display the constraints for the Employee table.


4. Create Synonym for table Employee as Emp and then run the
following queries and describe the results
a. Select * from Employee
b. Select * from [Human Resource].Employee
c. Select * from Emp
d. Select * from [Human Resource].Emp

5. Increase the budget of the project where the manager number is


10102 by 10%.
6. Change the name of the department for which the employee named
James works.The new department name is Sales.

7. Change the enter date for the projects for those employees who
work in project p1 and belong to department ‘Sales’. The new date is
12.12.2007.
8. Delete the information in the works_on table for all employees who
work for the department located in KW.

Part2: use training db


9. Try to Create Login Named(ITIStud) who can access Only student and
Course tablesfrom ITI DB then allow him to select and insert data into
tables and deny Delete and update .
10.Write a query to select the highest two salaries in Each Department for
instructors who have salaries. “using one of Ranking Functions”
11. Write a query to select a random student from each department.
“using one of Ranking Functions”

You might also like