LAB3

advertisement
University of Hail
Database Systems (ICS334)
Lab 3
Objectives:
1-Create Relationship between tables.
2- Creating Parameter Query.
3- Creating Cross Tab Query.
4- Creating Action Queries.
5- Adding Calculated Field to a query.
6- Creating a Query in Design View.
1
Example:
Launch Microsoft Access and open your Database Company.
Create relationship between the tables.
a. Click Relationships under the Tool menu
b. Select the two tables(Employee, department ), click Add, and then Close.
c. Select DepNo in the Department table, hold the mouse left key, drag it onto the DepNo
in the Employee table, and release the left key.
d. Check Enforce Referential Integrity.
e. Check Cascade Delete Related Records.
f. Check Cascade Update Related Fields.
Fname
Mname
Dname
Lname
Dnumber
Ssn
Email
Bdate
Salary
Status
MgrSsn
Activity 1:
Create Simple Query
1. List department number, department name, and number of employees in each department,
ordered by number of employees in each department by creating a query in Design view.
2
Dnumber
Dnumber
Dname
CountOfSsn
1
Headquarter
1
2
Finance
2
3
Sales
3
4
Research
2
Note: Select the SQL View under the View menu to see the SQL command.
2. Create a query that displays the maximum salary.
3. Create a query that display Last name of the employee whose first name starts with M.
4. Create a parameterized query that search for the data and show all information about an
employee by entering his Ssn.
5. Update the department name from sales to Sales and Purchas.
Activity 2:
1. Create a query that displays all the information for the employees who has salary between
4000 and 5000.
2. Create a query that delete the employee whose Ssn is 102222222.
 Do not forget to save your work.
 Do not turn the PC off.
3
Download