Adreeja Lab File Ism
Adreeja Lab File Ism
B.Com (Hons)-V
(Paper Code -307)
Give the steps to create table in design view and datasheet 17/08
4 view.
Explain Field Name, Data Types, Field Size with its 17/08
5 Description.
ID
FIRST NAME
LAST NAME
AGE
ADDRESS
Enter 5 records.
Steps to create a database, save the database and open the 19/08
database. Create a student database with S1 as table
8 containing the field names as SERIAL NO,
ENROLLMENT NO, NAME, AGE and ADDRESS.
Insert at least 10 records using the design view in MS
ACCESS.
S. No List of Programs Date Faculty sign
Define data type and explain the various data types 19/08
available in MS-ACCESS. Create a database DB1 with a
table T1 with the following fields as:
ST_NO.
ST_ID
9 ST_NAME
ST_ADD
ST_PHONE NO.
ST_HOBBIES
In the design view and add at least 10 records in the table.
25
18/11/21
34 Create an ER Diagram for Library Management system
Assignment 1
Ques. What do you mean by Data, Information, Database, DBMS, RDBMS?
Ans. Data
Data can be defined as a representation of facts, concepts, or instructions in a formalized
manner, which should be suitable for communication, interpretation, or processing by human
or electronic machine. In general concept, data refers to the fact that some existing
information or knowledge is represented in some form which can be suitable for better usage
and processing. Raw data is a collection of numbers or characters before it is corrected. Data
processing commonly occurs by stages, and the "processed data" from one stage may be
considered the "raw data" of the next stage. Data are measured, collected and reported and
analysed. I can be visualized using graphs, tables, images, or other analysis tool.
Information
Information is organized or classified data, which has some meaningful values for the
receiver. Information is the processed data on which decisions and actions are based . It is
associated with data, as data represent values attributed to parameters and information is data
in context and with meaning attached. Information also relates to knowledge, as knowledge
signifies understanding of an abstract or concrete concept.
Database
A database is an organized collection of structured information, or data, typically stored
electronically in a computer system. A database is usually controlled by a database
management system (DBMS). Together, the data and the DBMS, along with the applications
that are associated with them, are referred to as a database system, often shortened to just
database.
Data within the most common types of databases in operation today is typically modelled in
rows and columns in a series of tables to make processing and data querying efficient. The
data can then be easily accessed, managed, modified, updated, controlled, and organized.
Most databases use structured query language (SQL) for writing and querying data.
DBMS
Database management system (DBMS) is a software for storing and retrieving users' data
while considering appropriate security measures. It consists of a group of programs which
manipulate the database. The DBMS accepts the request for data from an application and
instructs the operating system to provide the specific data. In large systems, a DBMS helps
users and other third-party software to store and retrieve data.
DBMS allows users to create their own databases as per their requirement. The term
“DBMS” includes the user of the database and other application programs. It provides an
interface between the data and the software application.
RDBMS
Another step to open the Microsoft Access is click on the run function and type “ms-
access” and click “ok”
Right click on the mouse and click on to “new”, then another box will get opened
where you can see the Microsoft Access option. Click on that and the Microsoft
Access will get started.
Steps to open a database
In order to open a database, follow the following steps:
when you open the access, there will display an option of new
click on the new tab or can use the blank database
Objects of Database
MS Access uses “objects" to help the user list and organize information, as well as prepare
specially designed reports. There are four major objects of Database.
Tables
Queries
Forms
Reports
These objects allow us to enter, store, analyse and compile data.
Tables
Table is an object that is used to define and store data. When you create a new table, Access
asks you to define fields which is also known as column headings.
Each field must have a unique name, and data type.
Tables contain fields or columns that store different kinds of data, such as a name or
an address, and records or rows that collect all the information about a particular
instance of the subject, such as all the information about a customer or employee etc.
You can define a primary key, one or more fields that have a unique value for each
record, and one or more indexes on each table to help retrieve your data more
quickly.
Queries
An object that provides a custom view of data from one or more tables. Queries are a way of
searching for and compiling data from one or more tables.
Running a query is like asking a detailed question of your database.
When you build a query in Access, you are defining specific search conditions to find
exactly the data you want.
In Access, you can use the graphical query by example facility or you can write
Structured Query Language (SQL) statements to create your queries.
You can define queries to Select, Update, Insert, or Delete data.
You can also define queries that create new tables from data in one or more existing
tables.
Form
Form is an object in a desktop database designed primarily for data input or display or for
control of application execution. You use forms to customize the presentation of data that
your application extracts from queries or tables.
Forms are used for entering, modifying, and viewing records.
The reason forms are used so often is that they are an easy way to guide people
toward entering data correctly.
When you enter information into a form in Access, the data goes exactly where the
database designer wants it to go in one or more related tables.
Reports
Report is an object in desktop databases designed for formatting, calculating, printing, and
summarizing selected data.
You can view a report on your screen before you print it.
If forms are for input purposes, then reports are for output.
Anything you plan to print deserves a report, whether it is a list of names and
addresses, a financial summary for a period, or a set of mailing labels.
Reports are useful because they allow you to present components of your database in
an easy-to-read format.
You can even customize a report's appearance to make it visually appealing.
Access offers you the ability to create a report from any table or query.
Other database objects other than these four are macros and modules.
When you go to the field tab you can see that it is also automatically created. The ID
which is an AutoNumber field acts as our unique identifier and is the primary key for
this table. The ID field has already been created and we now want to rename it to suit
our conditions.
Click on the “name and caption” option in the ribbon in order to change or rename
the field. When you click on it a dialog box will appear.
1. By clicking on the “click to add” option you add fields to the table. Choose Short
Text as the field. When you choose short text, Access will then highlight that field
name automatically and all you have to do is type the field name.
2. Now type on the field names that you are required.
3. Once all the icons are added click on the save icon in order to save the data. Enter the
name of the table and click OK.
Creating a table using Design view
4. In the tables group, click on Table and you can see that it looks completely different
from the Datasheet View. In this view, you can see the field name and data type side
by side.
5. Then you have to fill data in the field and have to mention the type of data.
6. After entering the data click on the save icon in order to save the data.
ASSIGNMENT 3
Ques. Write features of SQL.
Ans. SQL is Structured Query Language, which is a computer language for storing,
manipulating and retrieving data stored in a relational database.
SQL is the standard language for Relational Database System. All the Relational Database
Management Systems (RDMS) like MySQL, MS Access, Oracle, Sybase, Informix,
Postgres and SQL Server use SQL as their standard database language.
Data Definition Language (DDL)
A Data Definition Language (DDL) is a computer language used to create and modify the
structure of database objects in a database. These database objects include views, schemas,
tables, indexes, etc. This term is also known as Data Description Language in some
contexts, as it describes the fields and records in a database table.
There are three commonly used command in DDL. They are:
7. CREATE: This command builds a new table and has a predefined syntax. The
CREATE statement syntax is:
CREATE TABLE [table name] ([column definitions]) [table parameters]
9. DROP: A drop command deletes a table, index or view. Drop statement syntax is:
DROP [table name/object name]
10. TRUNCATE: This command is used to remove all records from a table,
including all spaces allocated for records are removed. The TRUNCATE
statement syntax is:
TRUNCATE TABLE [table name]
11. RENAME: It is used to rename the objects. The RENAME statement syntax is:
RENAME TO new table name or
RENAME old name to new name
Data Query Language (DQL)
Data Query Language (DQL) refers to any computer programming language that request and
retrieves data from database and information systems by sending queries. It works on user
entered structured and formal programming command-based queries to find and extract data
from host databases.
The command used in DQL is:
12. SELECT: This command is used to retrieve data from the database table. The
SELECT statement syntax is:
SELECT [column 1, column 2] FROM [table name] or
SELECT *FROM [table name]
Data Manipulation Language (DML)
The commands of SQL that are used to insert data into the database, modify the data of the
database and to delete data from the database are collectively called as DML. Examples
include insert, update and delete.
The commands of DML are:
13. INSERT: To insert data into a table. The INSER statement syntax is:
INSERT INTO table name (column 1, column 2.…column N) VALUES (value 1,
value 2….value N)
14. UPDATE: To update the existing data in a table. The UPDATE statement syntax is:
UPDATE (table name) SET (column name) = (new value) WHERE (some
condition)
15. DELETE: This command is used to delete all the records from a table. The DELETE
statement syntax is:
DELETE FROM (table name) WHERE condition
ASSIGNMENT 4
Ques. Write steps to create a table in design view and datasheet view.
Ans. In a database the data are stored in the form of tables because the database objects
heavily depend the tables. Tables can be created by using database view and design view.
Datasheet view
A web datasheet view in an Access app displays online data arranged in rows and columns in
a web browser. It can allow data edits or not, as you prefer.
When you create a web datasheet view in Access, it opens in Design View, where you can do
any of the following:
16. Set the record source
17. Provide a caption for the view
18. Add automatic actions that happen when the view opens and when someone moves
between records using the view
19. Add custom actions that happen when someone clicks a button
20. Resize and move controls and set control properties
Creating a table in datasheet view
After opening a new database or a blank database, the Access automatically opens up
a table in datasheet view.
When you go to the field tab you can see that it is also automatically created. The ID
which is an AutoNumber field acts as our unique identifier and is the primary key for
this table. The ID field has already been created and we now want to rename it to suit
our conditions.
Click on the “name and caption” option in the ribbon in order to change or rename
the field. When you click on it a dialog box will appear.
21. By clicking on the “click to add” option you add fields to the table. Choose Short
Text as the field. When you choose short text, Access will then highlight that field
name automatically and all you have to do is type the field name.
22. Now type on the field names that you are required.
23. Once all the icons are added click on the save icon in order to save the data. Enter the
name of the table and click OK.
Design view
Most Access objects are displayed in Design view, which allows you to work with the
underlying structure of your tables, queries, forms, and reports. To create a new table in
Design view, you define the fields that will comprise the table before you enter any data. In
Design view for tables, each row corresponds to a field. You can edit, insert, and delete
fields in your database tables in Design view. You insert a field by adding a row, while you
delete a field by removing a row. You can also change field order by dragging a row selector
to a new position.
Creating a table in design view
24. In the tables group, click on Table and you can see that it looks completely different
from the Datasheet View. In this view, you can see the field name and data type side
by side.
25. Then you have to fill data in the field and have to mention the type of data.
26. After entering the data click on the save icon in order to save the data.
Difference
Datasheet View is a representation of the data in a database. Using this view, it is possible to
edit the data in the database. However, only minor changes can be made to the actual
database format. One such change that can be made to the format is adjusting the column
width of a table.
Design View helps with modifying the database format. Changes can be made to forms,
tables, or other database objects. Fields can also be configured to set appropriate keys and
restrictions on type of data entered in them. However, the actual data in the database cannot
be manipulated using this view.
ASSIGNMENT 5
Ques. What do you mean by field name, data type, field size, and description?
Ans. Field name
A field in Microsoft Access is a piece of information related to a single person or thing.
Related fields are grouped together to form a record. When you add a field by entering data in
Datasheet view, Access automatically assigns a generic name to the field. Access assigns the
name Field1 to the first new field, Field2 to the second new field, and so on. By default, a
field's name is used as its label wherever the field is displayed, such as a column heading on a
datasheet. Renaming fields so that they have more descriptive names helps make them easier
to use when you view or edit records.
Data type
Every field in a table has properties and these properties define the field's characteristics and
behaviour. The most important property for a field is its data type. A field's data type
determines what kind of data it can store. MS Access supports different types of data, each
with a specific purpose.
The data type determines the kind of the values that users can store in any given field.
Each field can store data consisting of only a single data type.
Date and time values for the years 100 through 8 bytes
Date/Time
9999.
Field size
The field's data type determines which other properties that you can set. he Field
Size property is especially important, because it determines the range of field values.
The Field Size property also determines how much disk space each Number field value
requires. Depending on the field size, the number can use exactly 1, 2, 4, 8, 12, or 16 bytes.
Description
The Description property is used to provide information about objects contained in the
Database window as well as about individual table or query fields. An object's description
appears next to the object's name in the Database window when you click Details on
the View menu.
ASSIGNMENT 6
Ques. Write steps to open an existing database.
Ans. If Access is already running, use the following procedure to open a database. Note, the
steps vary slightly depending upon your version of Access.
1. On the getting started page of Access, Click Open Other Files.
2. On the Open area of the Backstage view, click Browse.
3. Click a shortcut in the Open dialog box, or in the Look in box, click the drive or folder that
contains the database that you want.
4. In the folder list, browse to the folder that contains the database.
5. Then click on the database that is wanted to be opened.
ASSIGNMENT 7
Ques. Create a student database with a table Student-Details containing the fields
names as ID, First name, Last name, Age, Address. Insert 5 records using the design
view. Create another table using data sheet view
as STUDENT_COURSE with the field name as
• ID
• COURSE CODE
• COURSE NAME.
Enter 5 records.
Ans. In order to create a Student table the following steps are to be followed:
1. Open a new blank database in MS Access and name it as Student.
2. After opening a new database or a blank database, the Access automatically opens up
a table in datasheet view.
3. Rename the table as Student_Details.
4. After that enter the field names and data type that is needed in the design view of the
database and save it.
5. Then go to the datasheet view and fill all the information required, after which save
the database.
7. and fill all the information required, after which save the database.
ASSIGNMENT 8
Ques. Create a Student_Data with S1 as the table name containing the filed names as
Enrolment_no, name, age, date_of_birth, phone_no, email_id, address. Insert at least
10 records.
Ans. Steps to create a student data database are as follows:
1. Open a blank database and name it as Student_data.
2. After opening a new database or a blank database, the Access automatically opens up
a table in datasheet view.
3. Rename the table as S1.
4. After that enter the field names and data type that is needed in the design view of the
database and save it.
5. After completing the table go to the save icon and save the database.
ASSIGNMENT 9
Ques: Create a database DB1 with a table T1 with the following fields as:
ST_NO.
ST_ID
ST_NAME
ST_ADD
ST_PHONE NO.
ST_HOBBIES
In the design view and add at least 10 records in the table.
Steps to create a student data database are as follows:
1. Open a blank database and name it as Student_data.
2. After opening a new database or a blank database, the Access automatically opens up
a table in datasheet view.
3. Rename the table as T1.
4. After that enter the field names and data type that is needed in the design view of the
database and save it.
5. After completing the table go to the save icon and save the database.
ASSIGNMENT 10
Ques. Create a database named EMPLOYEE and create a table named
EMPLOYEE_DATA with the following fields as EMPLOYEE_ID,
EMPLOYEE_NAME, SSN_NO, EMPLOYEE_DESIGNATION,
EMPLOYEE_DEPARTMENT, DATE_OF_JOINING, SALARY and
YEAR_OF_EXPERIENCE. Insert 10 records and delete any two records and one field
(i.e., SSN_NO) from the table to show the output.
Ans. Steps to delete record
The deletion process is fairly simple, except when the record is related to other data and
resides on the "one" side of a one-to-many relationship. To maintain data integrity, by
default, Access does not let you to delete related data.
1. Open the table in Datasheet View or form in Form View.
2. Select the record or records that you want to delete.
To select a record, click the record selector next to the record, if the record selector is
available.
To extend or reduce the selection, drag the record selector (if it is available), or press
SHIFT+DOWN ARROW or SHIFT+UP ARROW.
3. Press DELETE, select Home > Records > Delete, or press Ctrl+Minus Sign (-).
Ans. 1. Employee names should be in upper case with field size equal to 10
Step 1: Open General in Design view
Step 2: Enter “>” in ‘Format’ for upper case
Step 3: Enter “10” in ‘Field size’.
Ques: Create a local template of “FACULTY” , insert 5 records and perform the
following queries on faculty template table:
2. Rename the table as faculty list and start entering the values.
5. Generate report for: All faculty category and faculty by department category
ASSIGNMENT 15
Ques. Create a database named as Student Database. With a table Student_Details with
the given fields as:
Stu_id
Stu_roll
Stu_name
Stu_age
Stu_dob
Stu_course
Stu_add
Stu_contact
Add at least 10 records in the table. Answer the following:
1. What is a primary key? Make a field Stu_id as the primary key in the table.
Also write the steps for the same.
2. What is a composite key? In the table male Stu_roll and stu_dob as the
composite key and write the steps for the same.
Ans. Student_details table
Primary key
A primary key is a special relational database table column (or combination of columns)
designated to uniquely identify each table record.
A primary key is used as a unique identifier to quickly parse data within the table. A table
cannot have more than one primary key.
A primary key’s main features are:
It must contain a unique value for each row of data.
It cannot contain null values.
Every row must have a primary key value.
A primary key might use one or more fields already present in the underlying data model, or
a specific extra field can be created to be the primary key.
Steps to create a primary key
1. Go to the design view and select the Stu_id.
2. Right click on the mouse and click on the primary key option.
OR
1. Go to the design view and select the Stu_id.
2. Click on the primary key option on the ribbon bar.
since the primary key is an unique function, therefore, the Access will detect the error when
recorded a same ID in the Stu_id field.
Composite key
A composite key, in the context of relational databases, is a combination of two or more
columns in a table that can be used to uniquely identify each row in the table. Uniqueness is
only guaranteed when the columns are combined; when taken individually the columns do
not guarantee uniqueness.
Steps
1. In the design view select the roll number and Stu_dob.
2. Either right click or choose the primary key from the ribbon bar, in order to make
both of them unique.
ASSIGNMENT 16
QUES: Create a company database with the following table Emp_details with the fields
as:
Emp_ID
Emp_name
Emp_designation
And make Emp_ID as the primary key. Create another table as Dept_details with the
fields as:
Dept_ID
Dept_name
Dept_location
Also create a table as Projects with the fields as:
P_ID
P_name
Designate primary key in all the tables. Establish a relationship between the table
Emp_details and Dept_details as 1:1, 1:M and M:1. Also, establish a relationship
between the table Emp_details and Projects as 1:1. Enforce referential integrity
constraint on it and write down the steps for the same.
Ans. MS Access uses table relationships to join tables when you need to use them in a
database object. There are several reasons why you should create table relationships before
you create other database objects, such as forms, queries, macros, and reports.
To work with records from more than one table, you often must create a query that
joins the tables.
The query works by matching the values in the primary key field of the first table
with a foreign key field in the second table.
When you design a form or report, MS Access uses the information it gathers from
the table relationships you have already defined to present you with informed
choices and to prepopulate property settings with appropriate default values.
When you design a database, you divide your information into tables, each of which
has a primary key and then add foreign keys to related tables that reference those
primary keys.
These foreign key-primary key pairings form the basis for table relationships and
multi-table queries.
For one to one relationship
The one to one relationship is used to relate one record from one table to one and only one
record in another table.
Steps to create a one to one relationship
Create three tables and name them as Emp_details, Dept_details and Project.
Close all the table and click on the Database tools in the ribbon bar.
In the database tools click on the relationships option.
Select Emp_details, Dept_details and Project and then click on the Add button to
add them to our view and then close the show table dialog box.
To create a relationship between the two tables, use the mouse, and click and hold
the Product ID field from Product table and drag and drop that field on the
Employee ID by hovering the mouse right over Employee ID from Emp_details.
When you release your mouse button, Access will then open the following window –
After that check box all the options in the dialog box and then click on the create
option.
The relationship is now saved automatically and there's no real need to click on the
Save button.
For one to many relationship
One to many relationships is where one record from a table has the potential to be
related to many records in another table.
Steps to create one to many relationship
Go to the database tool in the ribbon bar and click on the relationship option. If it is
an existing table then drag the Employee ID from Emp_details table to
Dep_location in the Dept_details table.
A dialog box will be opened. Click on all the check boxes and click on create.
The relationship is now saved automatically and there's no real need to click on the
Save button.
Now click on the Product table and click on the plus sign on the left side. Fill up the
details.
After filling the details click on the Emp_details table and Dept_details all the
information will be saved in those tables automatically.
ASSIGNMENT 17(a)
QUES: Explain in brief about the query object in MS Access 2007. Write steps to
execute queries using the query wizard. Create an Account_details table with the
following fields:
Acc_nor
Acc_type
Date_of_opening
Transaction_type
Balance
AccountH_name
Transaction_ID
Enter 12 records in the table and perform the following queries on it.
Display the Acc_nor in ascending order
Display the details of account where Acc_nor is 675
Display the details where Acc_nor is 675 and name is Ajay
Display the Acc_nor, Acc_type, AccountH_name, and balance is greater than
5000
Ans. In Access, queries are like questions that are asked to find related, even very specific,
information in a database. In queries, we sometimes use data from just one table and other
times from more than one. In Access, a query is a database object. It doesn’t store data.
Instead, it displays data that is stored in tables and it makes that data available for you to
work with. A query might show data from one or more tables, from other queries, or from a
combination of the two.
Steps to execute queries using query wizard
Create a blank database, create a table and name it as Account_details. Add all the fields
required and enter 12 records. After entering the records:
1. Select Create > Query Wizard.
5. Right click on the table Account_details Query and click on the Design view.
4. Display the Acc_nor, Acc_type, AccountH_name, and balance is greater than 5000
I. Click the Acc_nor, Acc_type, AccountH_name and Balance.
II. Under the Balance field enter >5000.
III. Click on the Run option.
IV. All those records will be displayed whose balance is greater than 5000.
ASSIGNMENT 17(b)
Ques. Create a table Student with the following fields:
Enrolment_nor
S_name
Course_id
Batch
Semester
Execute the following queries after entering 10 records in the table.
Display the list of students in batch 2017-2020
Display the Enrolment_nor 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.
Ans. Create a database and create a table named as Student. Enter the fields and records
required.
C. Display the list of students whose batch is 2017-2020 and the Course_id is 17.
Using query design
Write the command SELECT S_name FROM Student WHERE Batch=2017-20,
Course_id=17;
The records will be displayed.
D. Display the number of students whose Course_id is 44.
Using query design
In the query design, write the command SELECT COUNT(S_name) FROM
Student WHERE Course_id=44;
The records will be displayed.
ASSIGNMENT 18(a)
Ques. Create the following table CUSTOMER having the columns, data types
Field name Data type
Customer_id Number
Customer_name Text
Designation Text
City Text
Country Text
Phone Number
Insert the data into the table Customer and apply the queries.
Display customer details having designation Sales representative.
Retrieve customers who is living in Canada.
Show details of the customer whose name is Victoria.
Show details of the customer who lives in Sweden.
Show details of the customer who is owner.
Ans. Create a table in the new database of MS Access and name the table as Customer.
C. Display the marks along with the names where the marks are greater than 60
I. Click on the Marks and Names fields in the Student Query table.
II. Under the Marks filed write >60.
III. Click on the Run option.
IV. All the records will be displayed whose marks are greater than 60.
D. Display the name of the students whose name starts with the letter ‘A’
I. Select the Name field in the Student Query table.
II. Under the Name field write LIKE ‘A*’.
III. Click on the Run option.
IV. All the names which starts with the latter ‘A’ will be displayed.
F. Display all the details of the students who are older than years
I. Click on all the fields in the Student Query table.
II. Under the Age field write >10.
III. Click on the Run option.
IV. All the records of the students who are older than 10 years will be displayed.
ASSIGNMENT 18(c)
Ques. Create a table Employee with the following fields:
Emp_id, Emp_name, Contact_nor, Gender, Salary, Emp_grade, Designation,
Address
Execute the following queries on the table created:
Display the details of the employees
Display the employee ID whose name is Supriya
Display the name of the employee whose contact number is 9845486301
Display the details of the employee whose address is D-29, IITM Janakpuri
Display the name of the employee whose salary is >10000
Update the employee details, set the emp_grade equal to C whose salary is less
than 10000
Delete the record of the employees whose gender is male and designation is
manager
Display the name, designation and salary of all the employees whose name starts
with A
Update the employee details, set designation to assistant manager where
designation is trainee.
Display the employee id, name, salary and designation for the employee where
grade is A
Ans. Create a table in the name of Employee in the blank database and enter the records
required.
4. Display the details of the employee whose address is D-29, IITM Janakpuri
Write the query SELECT* FROM Employee WHERE Address=’D-29, IITM
Janakpuri’; and click on the RUN option.
The record will be displayed.
5. Display the name of the employee whose salary is >10000
In the query design, write down the query SELECT Emp_name FROM Employee
WHERE Salary>10000; and click on the RUN option.
The record will be displayed.
3. Update the employee details, set the emp_grade equal to C whose salary is less than
10000
Write the query, UPDATE Employee SET Emp_grade=’C’ WHERE
Salary<10000; and click on the YES option and then on RUN.
The records will be updated.
4. Delete the record of the employees whose gender is male and designation is manager
Write the query, DELETE FROM Employee WHERE Gender=’Male’ and
Designation=’Manager’; and click on the YES option and then RUN the query.
The records will be deleted.
5. Display the name, designation and salary of all the employees whose name starts with A
Write the query, SELECT Emp_name, Designation, Salary FROM Employee
WHERE Emp_name=’LIKE*A’; and click on the RUN option.
The records will be displayed.
6. Update the employee details, set designation to assistant manager where designation is
trainee.
In the query design, write the query, UPDATE Employee SET
Designation=’Assistant Manager’ WHERE Designation=’Trainee’; and click
on the RUN option.
The records will be updated.
7. Display the employee id, name, salary and designation for the employee where grade is
A
In the query design, write down the query, SELECT Emp_id, Emp_name,
Salary, Designation FROM Employee WHERE Emp_grade=’A’; and click on
the RUN option.
The records will be displayed.
ASSIGNMENT 19(a)
Ques: Create a table Employee with the following fields:
Emp_ID
Emp_name
Dept_name
Salary
Address
Date of joining
Perform the following queries:
Delete the records of the table whose Emp_ID=101
Delete the records of the employees whose Dept_name is HR and salary >10000
Delete the records of the employees whose name begins with S or salary>10000
Update the records of the employees, set Dept_name= IT where
Dept_name=Production
Update the records of the employees, set salary=15000 whose Dept_name is IT.
. In the blank database create a table named Employee and enter the records.
3. Delete the records of the employees whose name begins with S or salary>10000.
In the query design write down the query DELETE FROM Employee WHERE
Emp_name=’LIKE*S’ OR Salary>10000; and click YES and then on the RUN
option.
The records will be deleted.
4. Update the records of the employees, set the Dept_name as IT where the Dept_name is
Production
Write down the query UPDATE Employee SET Dept_name=’IT’ WHERE
Dept_name=’Production’; and click on YES in the dialog box and then on the
RUN option.
The records will be updated.
5. Update the records of the employees, set the salary =15000 whose Dept_name=IT.
Write down the query UPDATE Employee SET Salary=15000 WHERE
Dept_name=’IT’; in the query design and click YES and then click on the RUN
option.
The records will be updated.
ASSIGNMENT 19(c)
Ques: Create a table named as STUDENT_MARKS with the following fields as:
S_nor
Name
Marks
Execute the following queries after entering 10 records in the table.
Display the S_nor of those students whose names starts with L and ends with A
and marks less than 70.
Display the name and S_nor of those students who have scored marks equal to
95.
Display the names and marks of all those students who have scored between 75
and 90.
Ans. Create a database in which create a table named as Student_Marks. Enter 10 records as
required.
9. Display the name and S_nor of those students who have scored marks equal to 95
Tick on the check box of S_nor and Name fields.
Under the Marks field enter =95.
Click on the Run option.
All the names and s_nor of those students whose marks are equal to 95 will be
displayed.
10. Display the name and marks of all the students who have scored marks between 75 and
90
Click on the Name and Marks fields from the query table.
Under the Marks field enter BETWEEN 75 and 90.
Click on the Run option.
All the records of students who scored marks between 75 and 90 will be displayed.
ASSIGNMENT 20
Ques: Write SQL Queries using Data Manipulation Commands Insert record into
Table named Employee with Fields
EMP_ID
EMP_NAME
EMP_DESIGNATION
EMP_AGE
EMP_DEPARTMENT
EMP_SALARY
And make EMP_ID as the primary key.
4. Write a query to find the salary of a person where age is <= 26 and salary >=
25000 from Employee Table.
5. Write a query to find the name of Employee whose name is like “Ku%”.
Write a query to find the customer details using “IN” and “Between” operator where
age can be 25 or 27.
1. Create a database in which create a table named as employee. Enter 10 records as required.
find the salary of a person where age is <= 26 and salary >= 25000 from Employee
Table.
5. again create a query, go to its sql view, write the below command and hit run.
find the customer details using “IN” and “Between” operator where age can be 25 or
27.
ASSIGNMENT 21
Ques. Create a table employee with following fields:
Emp_id
Emp_name
Dept_name
Salary
Address
DOB
1. Find the employee ids of the employees having same salary.
2. Find the details of the employees working in the same dept.
3. Find employees id, emp_name of the employee having same DOB.
Ans. In a blank database create a table named Employee and enter the records required.
1. Find the employee ids of the employees having same salary.
Write the query SELECT DISTINCT E1.Emp_id FROM Employee E1,
Employee E2 WHERE E1. Salary=E2.Salary AND E1.Emp_id<>E2.Emp_id;
and click on the RUN option.
The records will be displayed.
Command-1 :
CREATE :
This command is used to create a new table in SQL. The user has to give information like
table name, column names, and their datatypes.
Syntax –
CREATE TABLE table_name
column_1 datatype,
column_2 datatype,
column_3 datatype,
....
);
Example –
We need to create a table for storing Student information of a particular College. Create
syntax would be as below.
CREATE TABLE Student_info
College_Id number(2),
College_name varchar(30),
Branch varchar(10)
);
Command-2 :
ALTER :
This command is used to add, delete or change columns in the existing table. The user
needs to know the existing table name and can do add, delete or modify tasks easily.
Syntax –
Syntax to add a column to an existing table.
ALTER TABLE table_name
Example –
In our Student_info table, we want to add a new column for CGPA. The syntax would be as
below as follows.
ALTER TABLE Student_info
Command-3 :
TRUNCATE :
This command is used to remove all rows from the table, but the structure of the table still
exists.
Syntax –
Syntax to remove an existing table.
TRUNCATE TABLE table_name;
Example –
The College Authority wants to remove the details of all students for new batches but wants
to keep the table structure. The command they can use is as follows.
TRUNCATE TABLE Student_info;
Command-4 :
DROP :
This command is used to remove an existing table along with its structure from the
Database.
Syntax –
Syntax to drop an existing table.
DROP TABLE table_name;
Example –
If the College Authority wants to change their Database by deleting the Student_info
Table.
DROP TABLE Student_info;
ASSIGNMENT 23
Ques: Write SQL Queries using Data Definition Commands like CREATE, DROP,
TRUNCATE, RENAME, ALTER.
Create Table named Student with Fields Student id, Name, Age, Course, Fees.
And apply above mentioned commands on the table.
1. Now write the alter command in the query and hit run
3. Delete
Rename
Drop
ASSIGNMENT 24
Data Manipulation Language (DML) commands in SQL deals with manipulation of data
records stored within the database tables. It does not deal with changes to database objects
and its structure. The commonly known DML commands are INSERT, UPDATE and
DELETE. Liberally speaking, we can consider even SELECT statement as a part of DML
commands. Albeit, it strictly forms part of the Data Query Language (DQL) command.
we will be learning about all the above mentioned DML commands in great detail in the
subsequent sections. But let us first have a look at this summary table for a brief overview on
each of them.
Command Description
SELECT Used to query or fetch selected fields or columns from a database table
INSERT Used to insert new data records or rows in the database table
UPDATE Used to set the value of a field or column for a particular record to a new
value
DELETE Used to remove one or more rows from the database table
Commands of DML
Now let us try to understand each of the above mentioned DML commands in detail one by
one.
1. SELECT
SELECT command or statement in SQL is used to fetch data records from the database table
and present it in the form of a result set. It is usually considered as a DQL command but it
can also be considered as DML.
The basic syntax for writing a SELECT query in SQL is as follows :
FROM table_name
SELECT customer_id,
sale_date,
order_id,
store_state
FROM customers;
INSERT commands in SQL are used to insert data records or rows in a database table. In an
INSERT statement, we specify both the column_names for which the entry has to be made
along with the data value that has to be inserted.
Here we have tried to insert a new row in the Customers table using the INSERT command.
The query accepts two sets of arguments, namely field names or column names and their
corresponding values.
Suppose if we have to insert values into all the fields of the database table, then we need not
specify the column names, unlike the previous query. Follow the following query for further
illustration.
3. UPDATE
UPDATE table_name
WHERE condition;
Having learnt the syntax, let us now try an example based on the UPDATE statement in SQL.
UPDATE customers
In this example, we have modified the value of store_state for a record where store_state was
‘NY’ and set it to a new value ‘DL’.
4. DELETE
DELETE statement in SQL is used to remove one or more rows from the database table. It
does not delete the data records permanently. We can always perform a rollback operation to
undo a DELETE command. With DELETE statements we can use the WHERE clause for
filtering specific rows.
In this example, we have removed a row from the customer’s table where store_state was
‘MH’ and customer_id was ‘1001’.
ASSIGNMENT 25
Ques: Define all aggregate functions with its work defined in sql.
Aggregate functions in DBMS take multiple rows from the table and return a value according
to the query.
Syntax −
AVG Function
This function returns the average value of the numeric column that is supplied as a parameter.
COUNT Function
The count function returns the number of rows in the result. It does not count the null values.
Example: Write a query to return number of rows where salary > 20000.
Types −
COUNT(*): Counts all the number of rows of the table including null.
COUNT( COLUMN_NAME): count number of non-null values in column.
COUNT( DISTINCT COLUMN_NAME): count number of distinct values in a
column.
MAX Function
The MAX function is used to find maximum value in the column that is supplied as a
parameter. It can be used on any type of data.
STDDEV Function
The STDDEV function is used to find standard deviation of the column specified as
argument.
VARIANCE Function
The VARIANCE Function is used to find variance of the column specified as argument.
Example −
A form in Access is a database object that you can use to create a user interface for a database
application. A "bound" form is one that is directly connected to a data source such as a table
or query, and can be used to enter, edit, or display data from that data source. Alternatively,
you can create an "unbound" form that does not link directly to a data source, but which still
contains command buttons, labels, or other controls that you need to operate your application.
This article focuses primarily on bound forms. You can use bound forms to control access to
data, such as which fields or rows of data are displayed. For example, certain users might
need to see only several fields in a table with many fields. Providing those users with a form
that contains only those fields makes it easier for them to use the database. You can also add
command buttons and other features to a form to automate frequently performed actions.
Think of bound forms as windows through which people see and reach your database. An
effective form speeds the use of your database, because people don't have to search for what
they need. A visually attractive form makes working with the database more pleasant and
more efficient, and it can also help prevent incorrect data from being entered.
1. In the Navigation Pane, click the table or query that contains the data you want to see on your
form.
2. On the Create tab, in the Forms group, click Form.
Access creates the form and displays it in Layout view. In Layout view, you can make design
changes to the form while it is displaying data. For example, you can adjust the size of the
text boxes to fit the data, if necessary.
If Access finds a single table that has a one-to-many relationship with the table or query that
you used to create the form, Access adds a datasheet to the form that is based on the related
table or query. For example, if you create a simple form that is based on the Employees table,
and there is a one-to-many relationship that is defined between the Employees table and
Orders table, the datasheet displays all the records in the Orders table that relate to the current
Employee record. You can delete the datasheet from the form if you decide you do not need
it. If there is more than one table with a one-to-many relationship to the table that you used to
create the form, Access does not add any datasheets to the form.
A split form gives you two views of the data at the same time — a Form view and a
Datasheet view.
A split form differs from a form/subform combination in that the two views are connected to
the same data source and are synchronized with one another at all times. Selecting a field in
one part of the form selects the same field in the other part of the form. You can add, edit, or
delete data from either part (as long as the record source is updatable, and you have not
configured the form to prevent these actions).
Working with split forms gives you the benefits of both kinds of forms in a single form. For
example, you can use the datasheet portion of the form to quickly locate a record, and then
use the form portion to view or edit the record.
To create a split form by using the Split Form tool:
1. In the Navigation Pane, click the table or query that contains the data that you want on your
form. Or open the table or query in Datasheet view.
2. On the Create tab, in the Forms group, click More Forms, and then click Split Form.
Access creates the form and displays it in Layout view. In Layout view, you can make design
changes to the form while it is displaying data. For example, you can adjust the size of the
text boxes to fit the data, if necessary. For more information about form views, see
the Understand Layout view and Design view section.
Create a form that displays multiple records by using the Multiple Items tool
When you create a form by using the Form tool, the form that Access creates displays a
single record at a time. If you want a form that displays multiple records but is more
customizable than a datasheet, you can use the Multiple Items tool.
1. In the Navigation Pane, click the table or query that contains the data you want to see on your
form.
2. On the Create tab, in the Forms group, click More Forms, and then click Multiple Items.
Access creates the form and displays it in Layout view. In Layout view, you can make design
changes to the form while it is displaying data.
When you use the Multiple Items tool, the form that Access creates resembles a datasheet.
The data is arranged in rows and columns, and you see more than one record at a time.
However, a Multiple Items form gives you more customization options than a datasheet, such
as the ability to add graphical elements, buttons, and other controls. For more information
about customizing your form, see the sections Fine-tune your form in Layout view and Fine-
tune your form in Design view.
To be more selective about what fields appear on your form, you can use the Form Wizard
instead of the various form-building tools previously mentioned. You can also define how the
data is grouped and sorted, and you can use fields from more than one table or query, as long
as you specified the relationships between the tables and queries beforehand.
1. On the Create tab, in the Forms group, click Form Wizard.
2. Follow the directions on the pages of the Form Wizard.
Note: If you want to include fields from multiple tables and queries on your form, do not
click Next or Finish after you select the fields from the first table or query on the first page
of the Form Wizard. Instead, repeat the steps to select a table or query, and click any
additional fields that you want to include on the form. Then click Next or Finish to continue.
3. On the last page of the wizard, click Finish.
If the wizard or the form-building tools don't meet your needs, you can use the Blank Form
tool to build a form. This can be a very quick way to build a form, especially if you plan to
put only a few fields on your form.
1. On the Create tab, in the Forms group, click Blank Form.
Access opens a blank form in Layout view, and displays the Field List pane.
2. In the Field List pane, click the plus sign (+) next to the table or tables that contain the fields
that you want to see on the form.
3. To add a field to the form, double-click it or drag it onto the form.
After the first field has been added, you can add several fields at once by holding down the
CTRL key, clicking several fields, and then dragging them onto the form at the same time.
The order of the tables in the Field List pane can change, depending on which part of the
form is currently selected. If the field you want to add is not visible, try selecting a different
part of the form and then try adding the field again.
4. Use the tools in the Header/Footer group on the Design tab to add a logo, title, or the date
and time to the form.
5. Use the tools in the Controls group of the Design tab to add a wider variety of controls to the
form.
For a slightly larger selection of controls, switch to Design view by right-clicking the form
and then clicking Design View.
Layout view Layout view is the most intuitive view to use for form modification, and it can
be used for almost all the changes that you would want to make to a form in Access.
In Layout view, the form is actually running. Therefore, you can see your data much as it will
appear when you are using the form. However, you can also change the form design in this
view. Because you can see the data while you are modifying the form, this is a very useful
view for setting the size of controls or performing almost any other task that affects the
appearance and usability of the form.
If you encounter a task that cannot be performed in Layout view, you can switch to Design
view. In certain situations, Access displays a message that states that you must switch to
Design view before you can make a particular change.
Design view Design view gives you a more detailed view of the structure of your form.
You can see the Header, Detail, and Footer sections for the form. The form is not actually
running when it is shown in Design view. Therefore, you cannot see the underlying data
while you are making design changes. However, there are certain tasks that you can perform
more easily in Design view than in Layout view. You can:
Add a wider variety of controls to your form, such as bound object frames, page breaks, and
charts.
Edit text box control sources in the text boxes themselves, without using the property sheet.
Resize form sections, such as the Form Header or the Detail section.
Change certain form properties that cannot be changed in Layout view.
After you create a form, you can easily fine-tune its design by working in Layout view. Using
the actual form data as your guide, you can rearrange the controls and adjust their sizes. You
can place new controls on the form and set the properties for the form and its controls.
To switch to Layout view, right-click the form name in the Navigation Pane and then
click Layout View.
Access shows the form in Layout view.
You can use the property sheet to change the properties for the form and its controls and
sections. To display the property sheet, press F4.
You can use the Field List pane to add fields from the underlying table or query to your form
design. To display the Field List pane:
On the Design tab, in the Tools group, click Add Existing Fields or use the keyboard
shortcut by pressing ALT+F8.
You can then drag fields directly from the Field List pane onto your form.
To add a single field, double-click it or drag it from the Field List pane to the section on the
form where you want it displayed.
To add several fields at once, hold down CTRL and click the fields that you want to add.
Then drag the selected fields onto the form.
You can also fine-tune your form's design by working in Design view. You can add new
controls and fields to the form by adding them to the design grid. The property sheet gives
you access to many properties that you can set to customize your form.
To switch to Design view, right-click the form name in the Navigation Pane and then
click Design View.
Access shows the form in Design view.
You can use the property sheet to change the properties for the form and its controls and
sections. To display the property sheet, press F4.
You can use the Field List pane to add fields from the underlying table or query to your form
design. To display the Field List pane:
On the Design tab, in the Tools group, click Add Existing Fields or use the keyboard
shortcut by pressing ALT+F8..
You can then drag fields directly from the Field List pane onto your form.
To add a single field, double-click it or drag it from the Field List pane to the section on the
form where you want it displayed.
To add several fields at once, hold down CTRL and click the fields that you want to add.
Then drag the selected fields onto the form.
ASSIGNMENT 27
Ques. Create two tables Employee ands 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 employees as well as the department in tabular form and write
the steps in create forms. Also provide the suitable title to both the 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. A "bound" form is one that is directly connected to a data source such
as a table or query, and can be used to enter, edit, or display data from that data source.
Create the tables Employee and Department.
Employee table
Department table
Creating form through Form wizard
In the database open the CREATE tab. In the forms group in the upper right-hand corner
there will be FORM WIZARD button.
The title of the form changed to Employee_form_wizard. After changing the title click on
the finish option.
The form is created using the Form wizard. Using the navigation button below, the records
can be changed from one to other.
New records can also be added in the form directly which will automatically be recorded in
the table.
Design view of Employee_form_wizard
The forms using the form wizard can be created similarly for the Department table also.
Design view of the Department_form_wizard
The record that is entered directly in the forms will be automatically recorded in the tables.
Design view of the employee_form
The forms using the form can be created similarly for the Department table also.
The forms using the multiple items can be created similarly for the Department table also.
Using the navigation buttons the we can move from one record to another. New record can
be added either directly on the form or on the table. But it automatically will the entered on
the either of the one. The title of the form can also be changed.
Design view of Employee_splitform
Similarly, the form can be created using the split form for the Department table.
3. a blank form will appear. Now add the existing records from the table by clicking on the
add existing records button.
Append the A grade holders from BBA_M2 to the newly created table
Go to append table. The dialog box appears. Add the table name and the hit ok and run.
ASSIGNMENT 30
Ques: Write SQL Queries using SQL Commands Create a Table Product with
Fields
PRO_ID
PRO_NAME
PRO_PRICE
And make PRO_ID as the primary key. Insert 10 Records into the Table.
4. Write a query to find the Name of Product where PRO_PRICE>= 500 from
PRODUCT Table.
5. Write a query to implement Aggregate Functions on field PRICE”.
Write a query to COUNT the number of Records in the Product Table.
find the Name of Product where PRO_PRICE>= 500 from PRODUCT Table.
ASSIGNMENT 32
Ques: Create an ER diagram for airline reservation system.
ASSIGNMENT 33
Ques: Create an ER diagram for employee management system.
Entities and their Attributes are
Employee Entity : Attributes of Employee Entity are Name, Id, Address, Gender, Dob
and Doj.
Id is Primary Key for Employee Entity.
Department Entity : Attributes of Department Entity are D_no, Name and Location.
D_no is Primary Key for Department Entity.
Project Entity : Attributes of Project Entity are P_No, Name and Location.
P_No is Primary Key for Project Entity.
Dependent Entity : Attributes of Dependent Entity are D_no, Gender and relationship.
ASSIGNMENT 34
Ques: Create an ER diagram for library management system.
Entities and their Attributes –
Book Entity : It has authno, isbn number, title, edition, category, price. ISBN is the
Primary Key for Book Entity.
Reader Entity : It has UserId, Email, address, phone no, name. Name is composite
attribute of firstname and lastname. Phone no is multi valued attribute. UserId is the
Primary Key for Readers entity.
Publisher Entity : It has PublisherId, Year of publication, name. PublisherID is the
Primary Key.
Authentication System Entity : It has LoginId and password with LoginID as Primary
Key.
Reports Entity : It has UserId, Reg_no, Book_no, Issue/Return date. Reg_no is the
Primary Key of reports entity.
Staff Entity : It has name and staff_id with staff_id as Primary Key.
Reserve/Return Relationship Set : It has three attributes: Reserve date, Due date,
Return date.