Introduction To MS Access Without Answers
Introduction To MS Access Without Answers
Access
MS. LESLYN BONACHITA - REAZOL
MS Access
Microsoft Access is a Database Management
System (DBMS) from Microsoft that
combines the relational Microsoft Jet
Database Engine with a graphical user
interface and software development tools.
It is a part of the Microsoft Office suite of
applications, included in the professional
and higher editions.
MS Access - Overview
Microsoft Access is a Database Management System (DBMS) from Microsoft
that combines the relational Microsoft Jet Database Engine with a
graphical user interface and software development tools. It is a member of
the Microsoft Office suite of applications, included in the professional and
higher editions.
Microsoft Access is just one part of Microsoft’s overall data management
product strategy.
It stores data in its own format based on the Access Jet Database Engine.
Like relational databases, Microsoft Access also allows you to link related
information easily. For example, customer and order data. However,
Access 2013 also complements other database products because it has
several powerful connectivity features.
It can also import or link directly to data stored in other applications and
databases.
MS Access - Overview
As its name implies, Access can work directly with data from other sources,
including many popular PC database programs, with many SQL (Structured
Query Language) databases on the desktop, on servers, on minicomputers,
or on mainframes, and with data stored on Internet or intranet web servers.
Access can also understand and use a wide variety of other data formats,
including many other database file structures.
You can export data to and import data from word processing files,
spreadsheets, or database files directly.
Access can work with most popular databases that support the Open
Database Connectivity (ODBC) standard, including SQL Server, Oracle, and
DB2.
Software developers can use Microsoft Access to develop application
software.
MS Access - Overview
Microsoft Access stores information which is called a
database. To use MS Access, you will need to follow these
four steps −
Database Creation − Create your Microsoft Access database and
specify what kind of data you will be storing.
Data Input − After your database is created, the data of every
business day can be entered into the Access database.
Query − This is a fancy term to basically describe the process of
retrieving information from the database.
Report (optional) − Information from the database is organized in a
nice presentation that can be printed in an Access Report.
MS Access – Overview: ARCHITECTURE
Access calls anything that can have a name an object.
Within an Access desktop database, the main objects are
tables, queries, forms, reports, macros, data macros,
and modules.
If you have worked with other database systems on
desktop computers, you might have seen the term
database used to refer to only those files in which you
store data.
But, in Access, a desktop database (.accdb) also includes
all the major objects related to the stored data,
including objects you define to automate the use of your
data.
MS Access - RDBMS
Microsoft Access has the look and feel of other Microsoft
Office products as far as its layout and navigational aspects
are concerned, but MS Access is a database and, more
specifically, a relational database.
Before MS Access 2007, the file extension was *.mdb, but in
MS Access 2007 the extension has been changed
to *.accdb extension.
Early versions of Access cannot read accdb extensions but MS
Access 2007 and later versions can read and change earlier
versions of Access.
An Access desktop database (.accdb or .mdb) is a fully
functional RDBMS.
MS Access - RDBMS
It provides all the data definition, data manipulation,
and data control features that you need to manage
large volumes of data.
You can use an Access desktop database (.accdb or
.mdb) either as a standalone RDBMS on a single
workstation or in a shared client/server mode across a
network.
A desktop database can also act as the data source for
data displayed on webpages on your company intranet.
When you build an application with an Access desktop
database, Access is the RDBMS.
Data Definition
Let us now understand what Data Definition is −
In document or a spreadsheet, you generally have complete freedom to define the
contents of the document or each cell in the spreadsheet.
In a document, you can include paragraphs of text, a table, a chart, or multiple
columns of data displayed with multiple fonts.
In spreadsheet, you can have text data at the top to define a column header for
printing or display, and you might have various numeric formats within the same
column, depending on the function of the row.
An RDBMS allows you to define the kind of data you have and how the data should
be stored.
You can also usually define rules that the RDBMS can use to ensure the integrity of
your data.
For example, a validation rule might ensure that the user can’t accidentally store
alphabetic characters in a field that should contain a number.
Data Manipulation
Working with data in RDBMS is very different from working
with data in a word processing or spreadsheet program.
Ina word processing document, you can include tabular data and
perform a limited set of functions on the data in the document.
You can also search for text strings in the original document and,
with ActiveX controls, include tables, charts, or pictures from
other applications.
Ina spreadsheet, some cells contain functions that determine the
result you want, and in other cells, you enter the data that
provides the source information for the functions.
Data Manipulation
An RDBMS provides you many ways to work with your data. For
example,
You can search a single table for information or request a
complex search across several related tables.
You can update a single field or many records with a single
command.
You can write programs that use RDBMS commands to fetch data
that you want to display and allow the user to update the data.
Access uses the powerful SQL database language to process data in
your tables. Using SQL, you can define the set of information that
you need to solve a particular problem, including data from
perhaps many tables.
Data Control
Spreadsheets and word processing documents are great for
solving single-user problems, but they are difficult to use when
more than one person needs to share the data.
When you need to share your information with others, RDBMS gives you
the flexibility to allow multiple users to read or update your data.
An RDBMS that is designed to allow data sharing also provides features to
ensure that no two people can change the same data at the same time.
The best systems also allow you to group changes (which is also known as
transaction) so that either all the changes or none of the changes appear
in your data.
You might also want to be sure that no one else can view any part of the
order until you have entered all of it.
Because you can share your Access data with other users, you might need to set
some restrictions on what various users are allowed to see or update.
MS Access - Objects
MS Access uses “objects" to help the user list and organize
information, as well as prepare specially designed reports.
When you create a database, Access offers you Tables,
Queries, Forms, Reports, Macros, and Modules. Databases in
Access are composed of many objects but the following are
the major objects −
Tables
Queries
Forms
Reports
CREATING A
DATABASE After selecting a template related to your
USING A Enter requirements, enter a name in the File name field and
you can also specify another location for your file if
you want.
TEMPLATE
Now, press the Create option. Access will download
Press that database template and open a new blank database
Create Blank Database
Sometimes database requirements can be so
specific that using and modifying the existing
templates requires more work than just
creating a database from scratch. In such case,
we make use of blank database.
Step 2 − Select
Blank desktop
database. Enter
the name and
click the Create
button.
Create Blank Database
Step 3 − Access
will create a new
blank database
and will open up
the table which is
also completely
blank.
MS Access - Data Types
Every field in a table has properties and these properties define
the field's characteristics and behavior. 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.
MS Access - Data Types
Type of Description Size
Data
Text or combinations of text and numbers, including numbers that do not Up to 255 characters.
Short Text
require calculating (e.g. phone numbers).
Lengthy text or combinations of text and numbers. Up to 63, 999
Long Text
characters.
Numeric data used in mathematical calculations. 1, 2, 4, or 8 bytes (16
Number bytes if set to Replication
ID).
Date/Time Date and time values for the years 100 through 9999. 8 bytes
Yes and No values and fields that contain only one of two values (Yes/No, 1 bit.
Yes/No True/False, or On/Off).
In Access 2013, we now have two data types —
short text and long text. In previous versions
of Access these data types were called text
and memo.
E.g. ArtistName
Customize the
Blank Table
STEP 3. Rename the First
Field
The first field in our table
is currently called ID.
ArtistId Number
GenreId Number
Create a Table in Design View
STEP2. Set up the Fields
Now add 4 fields and rename
the first. Set them up as
follows:
Field Name Data Type
ArtistId Number
GenreId Number
Create a Table in Design View
You can use Design View to create a tables, set up data types for
each field, specify default values, specify how data should be
entered and displayed, and more.
Generally speaking, most tasks can be achieved using either Design
View or Datasheet View, however there are some advanced
settings that can only be changed in Design View. Also, you might
find that you prefer to do certain tasks in Design View and other
tasks in Datasheet View.
Datasheet View vs Design View
Datasheet View
Datasheet View is what we used when we created our table
previously.
Datasheet View displays the table as a grid. The fields are displayed
as columns, and the records are displayed as rows. The field names
are listed as the column headers.
Datasheet View displays the data. If this table had data, it would be
displayed in the cells.
Each row represents a record. If the table had say, five records,
there would be five rows of data.
In Datasheet View, if you want to find out a field's data type, you
need to select that field, then select the Fields tab on the Ribbon.
The field's data type and other properties will be listed on the right
side of the Ribbon.
Datasheet View vs Design View
Design View
Design View doesn't display any data. Therefore, there's more
space available to display other settings.
InDesign View, the fields are listed vertically. They are listed
above and below each other as opposed to side-by-side.
In Design View, you can see the data type listed next to each
field.
The way Design View works is, when you click on a field (in the
top frame), the bottom frame displays the properties for that
field. You can then change these properties as required.
Create an Input Mask
An input mask is a set of simple rules that specifies the
format in which data can be entered into a field.
For example, an input mask of (999) 000-0000 could be used
to determine how phone numbers are entered. In this
example, the area code is optional, but the rest of the
number is must be entered. This is because, with any input
mask, a 9 specifies an optional number, a 0 specifies a
mandatory number.
This specifies how the date should be entered. Here's an break down of
each part:
The 99 part defines two optional numbers (i.e. for the day). So the user
has a choice of entering that part of the date. But if they do, it must
be a number.
The >L specifies that the user must enter an uppercase letter for that
part of the date.
The <LL specifies two lowercase letters for that part of the date.
The 0000 specifies four numbers for that part of the date.
Add Data to a Table: DATASHEET, FORM, SQL
Open Datasheet View and enter the Add Data using a Form
following data:
n many cases, you will want to create a
GenreId* Genre form for users to enter data. This will
allow them to enter data without needing
(Autonumber) Rock any technical knowledge about Microsoft
Access.
(Autonumber) Pop
Forms can also improve usability and
(Autonumber) Jazz
increase productivity. They can be used to
update data across multiple tables, saving
(Autonumber) Blues
the user from having to open multiple
(Autonumber) Hip Hop tables and enter data into each one. They
can also be use to provide extra data
validation.
Add Data to a Table: DATASHEET, FORM, SQL
Add Data using SQL
SQL(Structured Query
Language) is a query
language designed
specifically for relational
databases. Most relational
database management
systems use SQL.
Create a Relationship
Access allows you to create relationships between tables so that you can
query related data from multiple tables.
In relational database terms, a relationship is a situation where multiple
tables can contain related data that is linked by a common field.
A relationship consists of a parent table and a child table. The child table
references the parent table by having a field that matches a field in the
parent table. The child's field is referred to as a foreign key. The parent's
field is the primary key.
In a relationship, any data entered into the child's foreign key field must
match a value from the parent's primary key field.
By ensuring that the foreign key's data matches data in the primary key,
we know that all records in the child table will have an associated record
in the parent table.
Create a Relationship
Sample, ALBUMS and ARTISTS : STEP1: Open the Relationship Dialog
Will have a one-to-many
relationship between the Click Relationships from the
Albums and Artists table. Our Database Tools tab on the Ribbon.
relationship will determine
that an artist can have many The Show Tables dialog box should
albums, but an album can only appear. If it doesn't appear, click
belong to one artist. Show Tables.
Create a Relationship
One-to-One
A row in table A can have only one matching row in table B, and vice versa.
One-to-Many (or Many-to-One)
A row in table A can have many matching rows in table B, but a row in table
B can have only one matching row in table A.
Many-to-Many
A row in table A can have many matching rows in table B, and vice versa.
This is achieved through the use of a third table (commonly called a
junction table) that contains lookup data for both tables.
One-to-One
A row in table A can have only one matching row in table B,
and vice versa.
This is not a common relationship type, as the data stored in
table B could just have easily been stored in table A.
However, there are some valid reasons for using this
relationship type. A one-to-one relationship can be used for
security purposes, to divide a large table, and various other
specific purposes.
In the above example, we could just as easily have put an
HourlyRate field straight into the Employee table and not
bothered with the Pay table. However, hourly rate could be
sensitive data that only certain database users should see. So,
by putting the hourly rate into a separate table, we can
provide extra security around the Pay table so that only
certain users can access the data in that table.
MS Access - Query Data
A query is a request for data results, and for action on data. You can use a query to
answer a simple question, to perform calculations, to combine data from different
tables, or even to add, change, or delete table data.
As tables grow in size they can have hundreds of thousands of records, which
makes it impossible for the user to pick out specific records from that table.
With a query you can apply a filter to the table's data, so that you only get the
information that you want.
Queries that you use to retrieve data from a table or to make calculations are
called select queries.
Queries that add, change, or delete data are called action queries.
You can also use a query to supply data for a form or report.
In a well-designed database, the data that you want to present by using a form
or report is often located in several different tables.
The tricky part of queries is that you must understand how to construct one
before you can actually use them.
SQL
SQL is a standard language for storing, manipulating and
retrieving data in databases.
What is SQL?
- SQL stands for Structured Query Language
- SQL lets you access and manipulate databases
- SQL became a standard of the American National
Standards Institute (ANSI) in 1986, and of the
International Organization for Standardization (ISO) in
1987
What Can SQL do?
SQL can execute queries against a database
SQL can retrieve data from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new databases
SQL can create new tables in a database
SQL can create stored procedures in a database
SQL can create views in a database
SQL can set permissions on tables, procedures, and views
SQL CREATE DATABASE Statement
The CREATE DATABASE statement is used to create a new SQL
database.
Syntax
CREATE DATABASE databasename;
Create a TABLE
tblCustomer (with the following fields:
CustomerID, CustomerName, ContactName,
Address, City, PostalCode, and Country)
Database Tables
Create a Customer Table
The table above contains five records (one for each customer) and seven columns
(CustomerID, CustomerName, ContactName, Address, City, PostalCode, and Country).
SQL Statements
Most of the actions you need to perform on a database are done with SQL statements.
The following SQL statement selects all the records in the "Customers" table:
Example
SELECT * FROM tblCustomer;
SQL SELECT Statement
The SELECT statement is used to select data from a database.
The data returned is stored in a result table, called the result-set.
SELECT Syntax:
SELECT column1, column2, ...
FROM table_name;
Eg SELECT CustomerName FROM tblCustomer;
ANSWER
SQL SELECT DISTINCT Statement
ANSWER
SQL ALTER TABLE Statement
The ALTER TABLE statement is used to add, delete, or modify
columns in an existing table.
The ALTER TABLE statement is also used to add and drop various
constraints on an existing table.