Database Operations
Database Operations
Introduction to Database
About Data
1. The term data can be defined as set of isolated and unrelated raw facts with an
implicit meaning.
2. Data can be anything such as name of person, a number, images, sound etc.
About Database
1. A database is an organized collection of related data from which user can efficiently
retrieve the desired information.
2. Traditional databases are organized by fields, records and files.
3. A field is a single piece of information.
4. A record is one complete set of fields and a file is a collection of records.
5. In addition to the storage and retrieval of data, certain other operations can be
performed on a database and the operations include addition, alteration, updating
and deletion of data.
6. It is back-end of an application.
1
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Relational Database
1. A relational database is a collection of data items organized as a set of
formallydescribed tables from which data can be accessed or reassembled in
many different ways without having to reorganize the database tables.
2. The relational database was invented by E. F. Codd at IBM in 1970.
3. The standard user and application program interface to a relational database is
the structured query language (SQL).
4. SQL statements are used for both interactive queries for information from a
relational database and for gathering data for reports.
5. A relational database is a set of tables containing data fitted into predefined
categories.
6. Each table (which is sometimes called a relation) contains one or more data
categories in columns. Each row contains a unique instance of data for the
categories defined by the columns.
7. The following intuitive correspondence can be made
A relation is a file.
Each file contains only one record type.
The records have no particular order.
Every field is single-valued.
The records have a unique identifying field or composite field, called the
primary key field.
With a relational database, user can quickly compare information
because of the arrangement of data in columns.
The relational database model takes advantage of this uniformity to build
completely new tables out of required information from existing tables.
In other words, it uses the relationship of similar data to increase the
speed and versatility of the database.
2
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Integrity
Types of Integrity
1. There are four types of Integrity
Entity Integrity
Referential Integrity
Domain Integrity
Entity Integrity
The Entity Integrity states that in a base relation, primary key column values
cannot be null. (Null values are defined as "empty or containing no values").
A primary key is a minimal identifier that is used to identify columns
uniquely.
A DBMS product such as Microsoft Access automatically enforces entity
integrity by prohibiting null values in the primary key fields.
Referential Integrity
1. The referential integrity states that, if R2 (Child table) includes a foreign key FK
matching the primary key PK of some R1 (Parent table) then every value of FK in
R2 must
be equal to the value of PK in some rows of R1.
be wholly null, i.e. each column in that FK must be null.
2. For example, when adding a new row to a table containing FK, the table
containing the referenced PK must have matching values.
3
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Domain Integrity
1. Domain integrity states that the values in a table are legal according to the
physical and the logical domain definition.
2. For Instant explanation, the StudentID column domain might be
Physical : data type "numeric" ; Length "4 characters"
Logical : "The range of the number between 1000 and 4999"
3. Therefore, the field would only accept input of four-digit number between 1000
and 4999.
1. Open Microsoft Access 2010, click on Sample Templates. The Northwind icon
appears in the center of the window.
2. Click the Northwind icon
3. Click the Browse button.
4. The File New Database dialog box appears.
5. Locate the folder in which user wants to save the Northwind database.
6. Click OK. The File New Database window closed.
7. Click Create. MS-Access Creates the Northwind database and opens it. It shows
the warning message to open the database in trusted location.
4
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Creation of Database
1. A blank database is a database nothing in it. User must create all the tables,
forms, reports, queries and so on.
2. If user cannot find a template that suits their needs, they can create a blank
database.
3. Creating tables is the first step in building a database. Follow these steps to
create a blank database
Start MS-Access, click Blank Database.
Type the database name in the File Name field. MS-Access will
automatically append .accdb to the name.
Click the Browse button.
The File New Database window appears.
Locate the folder in where user wants to store the database.
Click OK, then click Create button.
Creation of Tables
5
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Type the nextfield name, MS-Access creates the field. User can continue
this process until fields in the table is to be created.
Press Enter without entering a field name to end their entries.
6
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
1. After creation of MS-Access table user can modify it, enter data into it manually
or import data from different application such as Excel.
2. To manipulate table structure user can
Enter records into the table
Modify a table
Select columns and rows Delete a record
Resize a column or row
Import a table into MS-Access from Excel
Enter Records
Modify a Table
1. To insert column
The insert option inserts a column before the selected column.
7
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Click the column head of the column before which user wants to insert a
column.
Right-click the column head that user wants to insert a column. A menu
appears. Click Insert field.
2. To move a column
User can use Move option to move a column from one place to another.
Move mouse pointer over the horizontal line under the column label.
Users mouse pointer turns into a four sided arrow.
Press left mouse button.
Click and drag the field to the new location. A dark line appears at the new
location.
Release left mouse button. MS-Access moves the column.
3. To delete columns
The Delete option permanently deletes columns and all the data
contained in them. User cannot undo a column after deleting.
Right-click the column head that user wants to delete a column. A menu
appears.
Click Delete field.
A warning dialog box will appear because delete option permanently
deletes the records. Click yes to delete.
Delete a Record
To delete a record
Select the record that user wants to delete.
Activate the Home tab.
Click Delete in the Records group. Or
Click Delete option from right-click. A prompt appears.
Click the Yes button.
8
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
9
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Dropping
Delete a field in Datasheet view
1. In the Navigation Pane, double-click the table from which you want to delete the
field. The table is opened in Datasheet view.
2. Select the field (the column) that user want to delete. Press Delete Field option
from right click. Or
3. Or on the Fields tab, in the Add & Delete group, click Delete button. Then click
yes to delete the column permanently.
1. Same method need to be followed to delete a record in datasheet view. Select the
record (the row) that user want to delete. Press Delete Record option from right
click. Or Press DELETE key. Then click yes to delete the record permanently.
1. If the tables that participate in the table relationship are open, close them.
2. User cannot delete a table relationship between open tables.
3. Then right click over the table name in the navigation pane and click delete
option.
4. Click yes in the warning dialog box to delete a table.
5. Thus MS-Access deletes that table permanently.
Query
1. User can use a query to view a subset of data or to answer questions about user
data.
2. For example, if user wants to view a list of student names and email address, but
user do not want to see addresses and other data, user can create a query that
displays the student's first name, last name and email address only.
10
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Click to choose the next table or query on which user want to base their
query.
Continue clicking tables or queries until user have all the tables and
queries their plan to use.
1. In Query Design view, each table has an option that allows user to display all of
the fields and all of the records in a table.
2. This option appears on the field line on the drop-down menu as the table name
followed by a period and an asterisk (tablename.*).
3. To display all records and all fields.
Sort a Query
1. While creating a query, user can sort the rows that they retrieve in ascending or
descending order by choosing the option of their need on the Sort row in Query
Design view.
2. Follow the steps to perform a sort
3. Open a table or query in Query Design view.
4. Choose the field names to retrieve them.
5. Under the field click the down-arrow and then choose Ascending or Descending.
6. Click the Run button. MS-Access retrieves the selected columns and displays the
rows in the order that user specified.
Save a Query
1. MS-Access forms are much like paper forms. User can use them to enter, edit, or
display data.
2. They are based on tables. When using a form, user can choose the format, the
arrangement, and which fields to display.
11
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Modify a Form
1. After user creates a form, it opens in Layout view, where user can modify it.
2. To change the size of a field
Click a side of the field and drag to change the width of the field.
Click the top or bottom of a field and drag to change the height of a field.
3. To move a datasheet
Click the datasheet to select it.
Click and drag the four-sided arrow in the upper-right corner to move the
datasheet.
4. To resize a datasheet
Click the datasheet to select it.
Click a side of the datasheet and drag to change the width.
Click the top or bottom of the datasheet and drag to change the height.
12
Topic : Database Operations
M1-R4: IT TOOLS AND BUSINESS SYSTEMS
Reports
1. Reports organize and summarize data for viewing online or for printing.
2. A detail report displays all of the selected records.
Creating Reports
1. User can include summary data such as totals, counts, and percentages in a detail
report.
2. A summary report does not list the selected records but instead summarizes the
data and presents totals, counts, percentages, or other summary data only.
3. MS-Access has several report generation tools that user can use to create both
detail and summary reports quickly.
4. Use of Report Button.
The Report button creates a simple report that lists the records in the
selected table or query in a column format.
5. To use the Report button
Open the Navigation pane.
Click the table or query on which user want to base their report.
Activate the Create tab.
Modify a Report
1. After creation of a report, user can modify it by adding groups or sorting, adding
fields, change labels and can perform many other tasks.
2. User can view a report in Report view, Layout view, design view and Print
Preview.
3. Change to Layout view
Open the report.
Activate the Home tab.
Click the View button. A menu appears.
Click Layout View. MS-Access changes to Layout view.
13