You are on page 1of 47

PRACTICAL NO.

17
Create a table employee with the following fields:
 Emp_id
 Emp_name
 Contact no.
 Gender
 Salary
 Emp_grade
 Designation
 Address
Execute the following queries on the table created:
 Display the details of the employee whose address is D-29, IITM-JANAKPURI.
 Display the name of the employees having salaries between 10,000 and 30,000.
 Update the employee details, set salary increased by 10% having grade A.
 Display the name, designation, and salary of all the employees whose names
contain ‘as’ as a substring.
 Calculate the maximum salary of employees.
 Delete the record of female employees.

ANS:
#STEPS
STEP 1: Create a database in MSAccess and then create a table named as “EMPLOYEE”.

STEP 2: Enter the field names and their corresponding data types in the design view.
STEP 3: Now go to the datasheet view and enter the records in the table.

STEP 4: Now go to the “Design” ribbon and then click on “Query Design”.

STEP 5: Now a dialogue box will appear, “Add” the table EMPLOYEE.
STEP 6: Now right click on the “Query 1” tab and then select “SQL View”.

STEP 7: For Query 1, “Display the details of the employees”, write the query as shown
below and then go to the “Design” ribbon and then click on “RUN”.

STEP 8: On running the query, the output will display the details of all the employees.
STEP 9: For Query 2, “Display the employee id of employee whose name is supriya”, write
the query as shown below and then go to the “Design” ribbon and click on “RUN”.

STEP 10: On running the Query, the output will display the Emp_id of the customer whose
name is “Supriya”.

STEP 11: For Query 3, “Display the name of the employee whose contact no. is
98454863011”, write the query as shown below and then click on “RUN”.
STEP 12: On running the Query, the output will display the name(s) of the employee(s)
whose contact no. is 98454863011.

STEP 13: For Query 4, “Display the details of the employee whose address is D-29, IITM,
JANAKPURI”, write the query as shown below and then click on “RUN”.

STEP 14: On running the query, the output will display the details of the employee(s) whose
address is “D-29, IITM, JANAKPURI”.
STEP 15: For Query 5, “Display the name of the employees whose salary is greater than
10,000”, write the query as shown below and then click on “RUN”.

STEP 16: On running the Query, the output will display the name(s) of the employee(s)
whose salary is greater than 10000.

STEP 17: For Query 6, “Update the employee details, set EMP_GRADE equal to C whose
salary is less than 10000.”, write the query as shown below and then click on “RUN”.
STEP 18: On running the query, a dialogue box will appear regarding the updation of the
number of records, Click on yes if you want to update the record(s).

STEP 19: Now save the table and the record(s) will be updated. Here, the Emp_grade of the
employee(s) whose salary is less than 10000 will be updated and the grade will be updated to
‘C’.

STEP 20: For Query 7, “Delete the record of the employee whose gender is male and
designation is manager”, write the query as shown below and then click on “RUN”.

STEP 21: On running the query, a dialogue box will appear regarding the deletion of the
number of records, Click on yes if you want to delete the record(s).
STEP 22: Now save the table and the record(s) will be deleted. Here, the record(s) of the
employee(s) will be deleted who is male and has manager as the designation. In the given
table it is the employee whose Emp_id is 105 and name is “Daksh” whose record is deleted
as shown below.

STEP 23: For Query 8, “Display the name, designation, and salary of all the employees
whose names begins with A”, write the query as shown below and then click on “RUN”.

STEP 24: On running the query, the output will display the Emp_name, Designation and
Salary of the employee(s) whose name starts with ‘A’.
STEP 25: For Query 9, “Update the employee details; set designation to assistant manager
where designation is trainee”, write the query as shown below and then click on “RUN”.

STEP 26: On running the Query, a dialogue box will appear regarding the updation of the
number of records, Click on yes if you want to update the record(s).

STEP 27: Now save the table and the record(s) will be updated. Here, the records of the
employees whose designation is “trainee’ will be changed/updated to ‘Assistant manager’.
STEP 28: For Query 10, “Display the employee id, name, salary and designation for the
employees where emp_grade is A.”, write the query as shown below and then click on
“RUN”.

STEP 29: On running the query, the output will display the Emp_id, Emp_name, Salary and
Designation of the employee(s) whose Emp_grade is ‘A’.
PRACTICAL NO. 19
Create a table Student with the following fields
 Enrollment_no
 Sname
 Course_id
 Batch
 Semester
 Marks
 percentage
Execute the following queries after entering 10 records in the table.
 Display the Enrollment_no of fourth-semester students.
 Display the list of students of batch ‘2017-2020’ and course_id is 17.
 Display the number of students in course_id 44.
 Update the semester by 6 those having percentages above 60%.
 Calculate the Sum and Avg of the total marks column.
 Calculate the MAX and MIN percentages of the student table.
 Delete the records of students having batch 2018-2021’.
ANS:
#STEPS
STEP 1: Create a database in MS Access named as “STUDENTS” and create a table in it
named as “STUDENT”.

STEP 2: Enter the field names and there corresponding data types in the design view.
STEP 3: Now enter the records in the table in the datasheet view.

STEP 4: In the “Create” ribbon, click on “Query Design” and then a dialogue box will
appear, “Add” the table “STUDENT”.
STEP 5: For Query 1, “Display the list of Students in batch ‘2017-2020’”, write the query as
shown below and then click on “RUN”.

STEP 6: On running the query, the output will display the list of students of batch ‘2017-
2020’.

STEP 7: For Query 2, “Display the Enrolment no of fourth semester students”, write the
query as shown below and then click on “RUN”.
STEP 8: On running the query, the output will display the Enrollment no. of the students
who are in fourth semester.

STEP 9: For Query 3, “Display the list of students of batch ‘2017-2020’ and course ID is
17”, write the query as shown below and then click on “RUN”.

STEP 10: On running the query, the output will display the details of the students of batch
‘2017-2020’ and course ID is 17.
STEP 11: For Query 4, “Display the number of students in course_id 44”, write the query as
shown below and then click on “RUN”.

STEP 12: On running the query, the output will display the number of students in course ID
44.
PRACTICAL NO. 25
Create a table employee with the following fields:
 Emp_id
 Emp_name
 Dept_name
 Salary
 Address
 Dob

1. Find the employee ids of the employees having the same salary.
2. Find the details of the employee working in the same dept.
3. Find the employee id and emp-name of the employee having the same dob.

ANS:
#STEPS

STEP 1: Create a database in MS Access and then create a table named as “EMPLOYEE”.

STEP 2: Enter the field names and their corresponding data types in the design view.

STEP 3: Now go to the datasheet view and enter the records in the table.
STEP 4: Go to “Design” ribbon and then click on “Query Design”.

STEP 5: A dialogue box will appear, “Add” the table “EMPLOYEE” to perform the queries.

STEP 6: Now right click on the “Query1” tab and then select “SQL View”. For Query 1,
“Find the employee ids of the employees having same salary”, write the query as shown
below and then go to the “Design” ribbon and then click on “RUN”.
STEP 7: On running the query, the output will display the Emp_id of the employees having
the same salary.

STEP 8: Foe Query 2, “Find the details of the employee working in the same dept.”, write
the query as shown below and then click on “RUN”.

STEP 9: On running the query, the output will display the details of the employees working
in same department.
STEP 10: For Query 3, “Find employee id, emp_name of the employee having same dob”,
write the query as shown below and then click on “RUN”.

STEP 11: On running the query, the output will display the Emp_name and Emp_id of the
employees having same DOB.
PRACTICAL NO. 26
Create 2 tables as EMPLOYEE and DEPARTMENT with the following table structure.
The employee should have the following fields:
 F_name
 L_name
 E_id
 Dob
 Add
 Salary
 D_no ()
The fields for dept table are:
 Dept_no
 D_name
 Mgr_no
 Mgr_doj
Perform the following queries on it:
 Select the employee’s f_name, d_no, and d_name from the above table.
 Select the f_name, and l_name and add the employee who works in the research
dept.
 Select the f_name, l_name, d_no, d_name for all the employees having
salary>40000
ANS:
#STEPS

STEP 1: Create a database in MS Access and then create a table and name it as
“EMPLOYEE”.

STEP 2: Enter the field names and their corresponding data types in the design view.
STEP 3: Now go to the datasheet view and enter the records in the table.

STEP 4: Now create another table named as “DEPARTMENT” in the same database.

STEP 5: Enter the field names and their corresponding data types in the design view.

STEP 6: Now go to the datasheet view and enter the records in the table
STEP 7: Now close the tables and then go to “Database Tools” ribbon and then click on
“Relationships” button.

STEP 8: A dialogue box will appear, add both the tables “EMPLOYEE” and
“DEPARTMENT”.

STEP 9: The following window will appear, now drag and drop the primary key of
“EMPLOYEE” table to the primary key of “DEPARTMENT” table.
STEP 10: A dialogue box will appear, tick all the checkboxes below and then click on
“Create”.

STEP 11: A ONE-TO-ONE relationship between “EMPLOYEE” table and


“DEPARTMENT” table as shown below.

STEP 12: Now go to “Design” ribbon and then click on “Query Design” and then a dialogue
box will appear, add both the tables “EMPLOYEE” and “DEPARTMENT”.
STEP 13: Now right click on the “Query1” tab and then select “SQL View”

STEP 14: For Query 1,”Select the employee’s f_name, d_no and d_name from the above
table”, write the query as shown below and then click on “RUN”.

STEP 15: On running the query, the output will display the F_name, D_no and D_name of
the employees.
STEP 16: For Query 2. “Select the f_name, l_name and add of the employee who works in
the research dept.”, write the query as shown below and then click on “RUN”.

STEP 17: On running the query, the output will display the F_name, L_name and Address of
the employee(s) working in research department.

STEP 18: For Query 3, “Select the f_name, l_name, d_no, d_name for all the employees
having salary>10000”, write the query as shown below and then click on “RUN”.
STEP 19: On running the query, the output will display the F_name, L_name, D_no and
D_name of the employee(s) whose salary is greater than 10000.
PRACTICAL NO. 27
Create two tables EMPLOYEE and DEPARTMENT with the following fields:
1. EMPLOYEE
 F_NAME
 L_NAME
 E_ID
 DOB
 ADDRESS
 SALARY
2. DEPARTMENT
 D_NO
 D_NAME
 MGR_NO
 MGR-DOJ
Create the forms for the employee as well as the dept table in tabular form and write
the steps to create the forms. Also, provide a suitable title for both forms and insert the
page no’s to it.
ANS:
A form in Access is a database object that you can use to create a user interface for a
database application.

#STEPS
STEP 1: Create a database in MS Access and then create a table named as “EMPLOYEE”.

STEP 2: Enter the field names and their corresponding data types in the design view.
STEP 3: Now go to the datasheet view and then enter the records in the table.

STEP 4: Now create another table named as “DEPARTMENT” in the same database.

STEP 5: Enter the field names and their corresponding data types in the design view.
STEP 6: Now go to the datasheet view and enter the records in the table.

#STEPS TO CREATE FORMS FOR “EMPLOYEE” TABLE.

METHOD 1
STEP 1: In the “Create” ribbon, in the forms group, click on “More Forms” option and then
select “FORM WIZARD”.

STEP 2: A dialogue box will appear.


STEP 3: Transfer all the “Available fields” to the “Selected fields” column and then click on
“Next”.

STEP 4: Another dialogue box will appear, select “Tabular” for the form to appear in tabular
form. And then click on Next.
STEP 5: Another dialogue box will appear, click on “Next”.

STEP 6: Another dialogue box will appear, write the suitable title for your form and then
click on “Finish”.
STEP 7: The form will be created as shown below.

STEP 8: For editing the form, right click on the “VIEW” button and then select “Layout
View”.
STEP 9: The form can be edited in the layout view as shown below and the form can also be
given suitable heading as shown.

METHOD 2
STEP 1: In the “Create” ribbon, in the forms group, click on “FORM” button.
STEP 2: The form will be created as shown below. At the bottom is the page/record number,
which can be changed with the help of the arrows provided.

STEP 3: On clicking the forward arrows the further records show up. The form can be edited
in “Layout View” and can be given a suitable heading from the “Layout View”.
METHOD 3
STEP 1: In the “Create” ribbon, in the forms group, click on “SPLIT FORM” button.

STEP 2: The form will appear as shown below; the form screen will be split between two
halves as the first half displaying a particular record and the second half displaying the whole
table.
STEP 3: Go to the layout view to edit the form and give it a suitable heading.

STEP 4: Also one can go to “Design View” to edit the form as shown below.
STEP 5: The form will appear in the design view, where the editing can be done as shown
below.

METHOD 4
STEP 1: In the “Create” ribbon, in the forms group, click on “MULTIPLE ITEMS” button.

STEP 2: The form will appear as shown below.


STEP 3: For editing the form and giving a suitable heading, go to the “Layout View” and the
form can be edited as shown below.

#STEPS FOR CREATING FORM FOR “DEPARTMENT” TABLE.

METHOD 1
STEP 1: In the “Create” ribbon, in the forms group, click on “More Forms” option and then
select “FPRM WIZARD”.

STEP 2: A dialogue box will appear, Transfer all the “Available fields” to the “Selected
fields” column and then click on “Next”.

STEP 3: Another dialogue box will appear, select “Tabular” for the form to appear in tabular
form. And then click on Next.
STEP 4: Another dialogue box will appear, click on “Next”.

STEP 5: Another dialogue box will appear, write the suitable title for your form and then
click on “Finish”.
STEP 6: The form will appear as shown below.

STEP 7: Go to the “Layout View” to edit the form.


STEP 8: The form can be edited and a suitable heading can be given to the form in the layout
view as shown below.

METHOD 2
STEP 1: In the “Create” ribbon, in the forms group, click on “FORM” button.
STEP 2: The form will be created as shown below.At the bottom is the page/record number,
which can be changed with the help of the arrows provided.

STEP 3: On clicking the forward arrows the further records show up. The form can be edited
in “Layout View” and can be given a suitable heading from the “Layout View”.
METHOD 3
STEP 1: In the “Create” ribbon, in the forms group, click on “SPLIT FORM” button.

STEP 2: The form will be created as shown below; the form screen will be split between two
halves as the first half displaying a particular record and the second half displaying the whole
table.
STEP 3: The form can be edited and can be given a suitable heading in the layout view as
shown below.
METHOD 4
STEP 1: In the “Create” ribbon, in the forms group, click on “MULTIPLE ITEMS” button.

STEP 2: The form will appear as shown below.


STEP 3: The form can be edited in the “Layout View” as shown below.

You might also like