Download as pdf or txt
Download as pdf or txt
You are on page 1of 137

Operating Database Application

By: Instructor Gemechis Bido


www.gemechisbido.com
Page Content
This is an introductory tutorial that covers the basics of MS
Access 2016.

Database Design Principle


01 Introduction to Database

Types of Database
02 Features of Database

The Design Process


03 Entity Relationship Diagram and Table Relationship

Introduction MS Access
04 Exploring Microsoft Access 2016

www.gemechisbido.com
Introduction to 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 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.
▪ It can also import or link directly to data stored in other applications and databases.
▪ 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.
www.gemechisbido.com
Basic Principle of Database
▪ Usability: Any information which we are storing in any organization should be meaningful for that organization.

▪ Database Extensibility: you can extend the database based on your requirements. For example, you can modify

an existing table by adding a new column.

▪ Data integrity: is the assurance that digital information is uncorrupted and can only be accessed or modified by those

authorized to do so. Data integrity describes data that's kept complete, accurate, consistent and safe throughout its

entire lifecycle in the following ways: Complete.

▪ Entity integrity: requires that each entity have a unique key. For example, if every row in a table represents

relationships for a unique entity, the table should have one column or a set of columns that provides a unique identifier

for the rows of the table.

▪ Domain integrity: is the collection of processes that ensure the accuracy of each piece of data in a domain. In this

context, a domain is a set of acceptable values that a column is allowed to contain. It can include constraints and other

measures that limit the format, type, and amount of data entered. www.gemechisbido.com
▪ Referential integrity: refers to the relationship between tables. Because each table in a database must have a primary
key, this primary key can appear in other tables because of its relationship to data within those tables. When a primary key

from one table appears in another table, it is called a foreign key .

▪ User-defined integrity: involves the rules and constraints created by the user to fit their particular needs. Sometimes
entity, referential, and domain integrity aren't enough to safeguard data.

▪ Performance: management is the process of monitoring, analysing and performing the subsequent performance tweaks of
a database system in order to optimize performance and increase efficiency.

▪ Availability: Database is a database system designed to operate continuously with no interruptions in service. So
database errors and failures must be handled by automatically failing over to redundant nodes when problems occur.

▪ Security: refers to the various measures organizations like yours take to ensure their databases are protected from internal
and external threats. Database security includes protecting the database itself, the data it contains, its database

management system, and the various applications that access it.


www.gemechisbido.com
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.

Architecture
o 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.
o 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.
o 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.
www.gemechisbido.com
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.
❑ 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.
www.gemechisbido.com
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.


www.gemechisbido.com
Data Manipulation
Working with data in RDBMS is very different from working with data in a word processing or spreadsheet program.
▪ In a 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.
▪ In a 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.
▪ 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.
www.gemechisbido.com
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.


www.gemechisbido.com
Advantage of
Database

www.gemechisbido.com
Migrate Access to SQL Server
When it's time for your Access database to go to the next level, migrate your data to SQL Server which supports larger
amounts of data, more concurrent users, and greater capacity.
Contained databases have some unique threats that should be understood and mitigated by SQL Server Database Engine
administrators. Most of the threats are related to the USER WITH PASSWORD authentication process, which moves the
authentication boundary from the Database Engine level to the database level. Users in a contained database that have
the ALTER ANY USER permission, such as members of the db_owner and db_accessadmin fixed database roles, can grant
access to the database without the knowledge or permission or the SQL Server administrator.

www.gemechisbido.com
Database Design Basics
A properly designed database provides you with access to up-to-date,
accurate information. Because a correct design is essential to achieving
your goals in working with a database, investing the time required to
learn the principles of good design makes sense.
Some database terms to know
Access organizes your information into tables: lists of rows and columns
reminiscent of an accountant’s pad or a spreadsheet. In a simple
database, you might have only one table. For most databases you will
need more than one. For example, you might have a table that stores
information about products, another table that stores information about
orders, and another table with information about customers.

Important: Access provides design experiences that let you create database applications for the Web. Many design
considerations are different when you design for the Web. This article doesn't discuss Web database application design.
For more information, see the article Build a database to share on the Web.
www.gemechisbido.com
Concepts and Terms
Let’s start by learning some basic terms and concepts. To design a useful database, you create tables that focus on
one subject. In your tables, you capture all the data needed for that subject in fields, which hold the smallest possible
unit of data.
▪ Relational databases: A database in which data is divided into tables, which are kind of like spreadsheets. Each
table has just one subject, such as customers (one table) or products (another table).
▪ Records and fields: Storage for the discrete data in a table. Rows (or records) store each unique data point, such
as the name of a customer. Columns (or fields) isolate the information being captured about each data point into
the smallest possible unit—first name might be one column and last name might be another.
▪ Primary key: A value that ensures each record is unique. For example, there might be two customers with the
same name, Elizabeth Andersen. But one of the Elizabeth Andersen records has the number 12 as its primary key
and the other has a primary key of 58.
▪ Parent-child relationships: Common relationships between tables. For example, a single customer may have
multiple orders. Parent tables have primary keys. Child tables have foreign keys, which are values from the
primary key that show how the child table records are linked to the parent table. These keys are linked by
a relationship.
www.gemechisbido.com
What is Good Database
Design?
Two principles are fundamental to good database design:
▪ Avoid duplicate information (also called redundant data). It wastes space and increases the
likelihood of errors.
▪ Ensure that data is correct and complete. Incomplete or erroneous information flows through in
queries and reports and may ultimately lead to misinformed decisions.
To help with these issues:
▪ Divide database information into subject-based tables with a narrow focus. Avoid duplicating
information in multiple tables. (For example, customer names should go in only one table.)
▪ Join the tables together using keys instead of duplicating data.
▪ Include processes that support and ensure the accuracy and integrity of database information.
▪ Design your database with your data processing and reporting needs in mind.
To improve the long-term usefulness of your databases, follow these five design steps:
www.gemechisbido.com
www.gemechisbido.com
Step 1: Determine the purpose of your database
Before you start, have a goal for your database.
To keep your design focused, summarize the purpose of the database and refer to the summary often. If you want a small
database for a home-based business, for example, you might write something simple, like, “The customer database keeps a list
of customer information for the purpose of producing mailings and reports.” For an enterprise database, you might need
multiple paragraphs to describe when and how people in different roles will use the database and its data. Create a specific and
detailed mission statement to refer to throughout the design process.

Step 2: Find and organize required information


Gather all of the types of information you want to record, such as your product names and order numbers.
Start with your existing information and tracking methods. For example, maybe you currently record purchase orders in a ledger
or you keep customer information on paper forms. Use those sources to list the information you currently capture (for example,
all the boxes on your forms). Don’t worry about making your first list perfect—you can fine-tune it over time. But do consider all
the people who use this information, and ask for their ideas. Next, think about what you want out of the database and the types
of reports or mailings you want to produce. Then, make sure you’re capturing the information required to meet those goals.

Tip: Remember to break each piece of information into its smallest useful part, such as first name and last name for a
customer table. In general, if you want to sort, search, calculate, or report based on an item of information (such as customer
last name), you should put that item in its own field.
Step 3: Divide information into tables
Divide your information items into major entities or subjects, such as products, customers, and orders. Each subject
becomes a table.
o After you have your list of required information, determine the major entities (or subjects) you need to organize your data.
Avoid duplicating data across entities.
o The major entities are: customers, suppliers, products, and orders. So start out with those four tables: one for facts about
customers, one for facts about suppliers, and so on. This may not be your final design, but it’s a good starting point.

Note: The best databases contain multiple tables. Avoid the temptation to place all your information in a single table. This results
in duplicate information, larger database size, and increased errors. Design to record each fact just once. If you find yourself
repeating information, such as a supplier address, restructure your database to place that information in a separate table.

To understand why more tables are better than fewer, consider the table shown here:

www.gemechisbido.com
Step 4: Turn information items into columns
Decide what information you need to store in each table. These discrete pieces of data become fields in
the table. For example, an Employees table might include fields such as Last Name, First Name, and Hire
Date.
▪ After you’ve chosen the subject for a database table, the columns in that table should only store facts about that
single subject. For instance, a product table should store facts only about products—not about their suppliers.
▪ To decide what information to track in the table, use the list you created earlier. For example, the Customers
table might include: First Name, Last Name, Address, Send Email, Salutation, and Email Address. Each record
(customer) in the table contains the same set of columns, so you store exactly the same information for each
customer.
▪ Create your first list, and then review and refine it. Remember to break information down into the smallest
possible fields. For example, if your initial list has Address as a field, break that down into Street Address, City,
State, and Zip Code—or, if your customers are global, into even more fields. That way, for example, you can do
mailings in the proper format or report on orders by state.
▪ After you have refined the data columns in each table, you are ready to choose each table's primary key.
www.gemechisbido.com
Step 5: Specify primary keys
Choose each table’s primary key. The primary key, such as Product ID or Order ID, uniquely identifies each record.
If you don’t have an obvious, unique identifier, use Access to create one for you.
▪ You need a way to uniquely identify each row in each table. Remember the earlier example where two customers
have the same name? Because they share a name, you need a way to separately identify each one.
▪ So every table should include a column (or set of columns) that uniquely identifies each row. This is called
the primary key and is often a unique number, such as an employee ID number or a serial number. Access uses
primary keys to quickly associate data from multiple tables and to bring the data together for you.
▪ Sometimes the primary key consists of two or more fields. For example, an Order Details table that stores line
items for orders might use two columns in its primary key: Order ID and Product ID. When a primary key employs
more than one column, it is also called a composite key.

www.gemechisbido.com
www.gemechisbido.com

If you already have a unique identifier for the information in a table, such as product numbers that uniquely
identify each product in your catalogue, use that, but only if the values meet these rules for primary keys:
▪ The identifier will always be different for each record. Duplicate values are not permitted in a primary key.
▪ There is always a value for the item. Every record in your table must have a primary key. If you are using
multiple columns to create the key (like Part Family and Part Number), both values must always be
present.
▪ The primary key is a value that doesn’t change. Because the keys are referenced by other tables, any
change to a primary key in one table means a change to it everywhere it’s referenced. Frequent changes
increase the risk of errors.
If you don’t have an obvious identifier, use an arbitrary, unique number as the primary key. For example, you
might assign each order a unique order number for the sole purpose of identifying the order.

Tip: To create a unique number as the primary key, add a column using the AutoNumber data type. The AutoNumber data
type automatically assigns a unique, numeric value to each record. This type of identifier contains no factual information
describing the row it represents. It’s ideal for use as a primary key because the numbers don’t change unlike a primary key
that contains facts about a row, like a telephone number or a customer name.
Types of Database
▪ A database is an organized collection of data, generally stored and accessed electronically from a computer system.

▪ Where database are more complex they are often developed using formal design and modeling techniques.

Relational Database

DB
Distributive Database

Cloud Database

www.gemechisbido.com
Relational Database
▪ A relational database is a type of database that stores and
provides access to data points that are related to one another.
Relational databases are based on the relational model, an
intuitive, straightforward way of representing data in tables.

▪ Is a collection of data items with pre-defined relationships between


them. These items are organized as a set of tables with columns
and rows.

▪ Tables are used to hold information about the object to be


represented in the database. Each columns in a table holds a
certain kinds of data and a field stores the actual value of an
attribute.

▪ The row in a table could be marked with a unique identifier called


“PRIMARY KEY” and the row among multiple tables can be made
related using “FOREIGN KEY”.
www.gemechisbido.com
Distributive Database
• A distributed database is a database that runs and stores data across multiple computers, as opposed to doing everything on
a single machine. Typically, distributed databases operate on two or more interconnected servers on a computer network.
Each location where a version of the database is running is often called an instance or a node.

• First, distributing the database increases resilience and reduces risk. If a single-instance database goes offline (due to a
power outage, machine failure, scheduled maintenance, or anything else) all of the application services that rely on it will go
offline, too.

• Second, distributed databases are generally easier to scale. In the context of a growing business, the storage and
computing requirements for the database will increase over time, and not always at a predictable rate.

• Third, distributing the database can improve performance. Depending on how it is configured, a distributed database
may be able to operate more efficiently than a single-instance database because it can spread the computing workload
between multiple instances rather than being bottlenecked by having to perform all reads and writes on the same machine.

• Fourth, geographically distributing the database can reduce latency. Although not all distributed databases support
multi-region deployments, those that do can also improve application performance for users by reducing latency.

www.gemechisbido.com
Broadly, there are two types of distributed databases:
1. NoSQL
2. Distributed SQL
One of the main goals of a distributed database is high availability:
making sure the database and all of the data it contains are available at
all times. But when a database is distributed, its data is replicated across
multiple physical instances, and there are several different ways to
approach configuring those replicas.
Active-passive
The first, and simplest, is an active-passive configuration. In an active-
passive configuration, all traffic is routed to a single “active” replica, and
then copied to the other replicas for backup.
Active-active
In active-active configurations, there are multiple active replicas, and
traffic is routed to all of them. This reduces the potential impact of a
replicating being offline, since other replicas will handle the traffic
automatically.
www.gemechisbido.com
Cloud Database
A cloud database is a database built to run in a public or hybrid cloud environment to help organize, store, and
manage data within an organization. Cloud databases can be offered as a managed database-as-a-service (DBaaS)
or deployed on a cloud-based virtual machine (VM) and self-managed by an in-house IT team.

Key features:
▪ A database service built and accessed through a cloud platform
▪ Enables enterprise users to host databases without buying dedicated
hardware
▪ Can be managed by the user or offered as a service and managed
by a provider
▪ Can support relational databases (including MySQL
and PostgreSQL) and NoSQL
databases (including MongoDB and Apache CouchDB)
▪ Accessed through a web interface or vendor-provided API
www.gemechisbido.com
Database Object
▪ A database object is any defined object in a database that is used to store or reference data. Anything which we
make from create command is known as Database Object. It can be used to hold and manipulate the data.
▪ A database object in a relational database is a data structure used to either store or reference data. When a
database object is created, a new object type cannot be created because all the various object types created
are restricted by the very nature, or source code, of the relational database model being used, such as Oracle,
SQL Server or Access.
Type of Database Objects
▪ Metadata – is a “data about data” or synonymously called table structure that defines what type of data your
data is. Tables - A table is a collection of data about a specific topic, such as products or suppliers recently, we
define it as a file but technically it was defined as a container or a worksheet-like container where the collection
of data has been stored. Basic Component of a Table:
1) Meta Data – Database Structure
2) Field – Column – Data
3) Fieldname
4) Record - Row – Information
www.gemechisbido.com
Get to Know Database
Objects
Access provides six database objects that, when combined, help you take full advantage of your data. Learn the role
that each object plays.
Tables
Access organizes your information into tables: lists of rows and columns reminiscent of an accountant’s pad or a
spreadsheet. Each table stores information about a specific subject, so most databases include more than one table.

Each row in the table is called a record, and each column is called a field. A record contains all the specific
information for a particular entity, such as a customer or an order. A field is a single item of information about that
entity. In the Products table, for instance, each row or record would hold information about one product. Each column
or field holds some type of information about that product, such as its name or price. If you aren’t already familiar with
them, learn the basics of databases.
www.gemechisbido.com
Queries
In a well-designed database, the data that you want to present through a form or report is usually located in multiple tables.
You use a query to pull that information from various tables and to assemble it for display in a form or report.
A query can be a request for data results from your database, or it can be used to perform an action on the data, or it might be
both. Use queries to get answers to simple questions, perform calculations using data, combine data from different tables, and
add, change, or delete data from a database.
There are many types of queries, but the two basic types are:

Major query types Use

Select To retrieve data from a table or make calculations.

Action Add, change, or delete data. Each task has a specific type of action query. Action queries are
not available in Access web apps.

Forms
Forms are like display cases in stores—they make it easier to view or get to the database items you want. Similar to paper
forms, Access forms are objects through which you or other users can add, edit, or display the data stored in your Access
desktop database. It’s important to design your form with use in mind. For example, if it’s for multiple users, a well-designed
form helps to make data entry accurate, fast, and efficient.
www.gemechisbido.com
Reports
Reports offer a way to view, format, and summarize information from your Access database. For example, create a simple report
of phone numbers for all your contacts or a summary report on the total sales across different regions and time periods.
Reports are handy when you want to present the information in your database to:
▪ Display or distribute a summary of data.
▪ Archive snapshots of the data.
▪ Provide details about individual records.
▪ Create labels.

Macros
A macro is a tool that allows you to automate tasks and add functionality to your forms, reports, and controls. For example, if you
add a command button to a form and associate the button's On Click event to a macro, it then performs a command each time
the button is clicked. Access provides a design environment to help you create macros. Essentially, you use a simplified
programming language to build a list of actions to perform. Some actions require additional information, like which field to display
fill in. The design environment makes it easier to create macros, as you select from lists of actions and fill in information.

Modules
Modules are VBA code that you write to automate tasks in your application and to perform higher end functions. You write
modules in the VBA programming language. A module is a collection of declarations, statements, and procedures that are
stored together as a unit. www.gemechisbido.com
Normalization
Normalization is a database design technique that reduces data redundancy and eliminates undesirable
characteristics like Insertion, Update and Deletion Anomalies. Normalization rules divides larger tables into smaller
tables and links them using relationships. The purpose of Normalisation in SQL is to eliminate redundant
(repetitive) data and ensure data is stored logically.
• Normalization is the process of organizing the data in the database.
• Normalization divides the larger table into smaller and links them using relationships.
• The normal form is used to reduce redundancy from the database table.
Data modification anomalies can be categorized into three types:
▪ Insertion Anomaly: Insertion Anomaly refers to when one cannot insert a new tuple into a relationship due
to lack of data.
▪ Deletion Anomaly: The delete anomaly refers to the situation where the deletion of data results in the
unintended loss of some other important data.
▪ Updatation Anomaly: The update anomaly is when an update of a single data value requires multiple rows
of data to be updated.
www.gemechisbido.com
Types of Normal Forms:
Normalization works through a series of stages called Normal forms. The normal forms apply to individual
relations. The relation is said to be in particular normal form if it satisfies constraints.

Normal Form Description

1NF A relation is in 1NF if it contains an atomic value.

2NF A relation will be in 2NF if it is in 1NF and all non-key attributes are fully functional dependent on the
primary key.

3NF A relation will be in 3NF if it is in 2NF and no transition dependency exists.

BCNF A stronger definition of 3NF is known as Boyce Codd's normal form.

4NF A relation will be in 4NF if it is in Boyce Codd's normal form and has no multi-valued dependency.

5NF A relation is in 5NF. If it is in 4NF and does not contain any join dependency, joining should be
lossless.
www.gemechisbido.com
Primary Key
www.gemechisbido.com

▪ A primary key, also called a primary keyword, is a column in a relational database table that's
distinctive for each record. It's a unique identifier, such as a driver's license number, telephone number
with area code or vehicle identification number (VIN). A relational database must have only one primary key.

▪ It means it should not have any duplicate value. Also, it doesn’t contain NULL value.
▪ Primary Key is the unique identification of one record. There is a uniquely identification number, such as ID
number, a serial number, a code that serves as a primary key.
Customer
• A primary key generally focuses on the uniqueness of the table.
c-id
• Table allows only one primary key. c-name
• The primary key doesn’t allow null values. c-age

• It can identify the record uniquely in the database table. c-sex

• In primary key, the value can’t be removed from the parent table.
c-phone
c-address
• Its restriction can be completely defined on the temporary tables.
c-employee Primary Key
Foreign Key
A Foreign Key is a column or columns of data in one table that refers to the unique data values often the

primary key data in another table. Foreign keys link together two or more tables in a relational database.

▪ The Foreign Key provides the link between the two tables.

▪ A foreign key is generally used to build a relationship between the two tables.

▪ The major purpose of the foreign key is to sustain data integrity between two separate instances of an entity.

• A foreign key contains values that correspondent to values in the primary key of another table

• A foreign key is a field in the table that is the primary key in another table.

• Table can allow more than one foreign key.

• Foreign key accept multiple null values.

• In this, the value can be deleted from the child table.

• Its restriction can not be defined on the global or local temporary tables.
www.gemechisbido.com
www.gemechisbido.com
Database Relationship
Are associations between tables that are created using join statements to retrieve data. Each primary
key value relates to none or only one record in the related table. Most one-to-one relationships are
forced by business rules and do not flow naturally from the data.
Allow you to describe the connections between different database tables in powerful ways. Once you’ve
described the relationships between your tables, you can later leverage that information to perform
powerful cross-table queries, known as joins. Is a logical connection between two tables.
Types of Database Relationships
1) One-to-One Relationships: occur when each entry in the first table has one, and only one,
counterpart in the second table.
2) One-to-Many Relationships: Is the most common type of database relationship.
3) Many-to-Many Relationships: occur when each record in the first table corresponds to one or
more records in the second table and each record in the second table corresponds to one or
more records in the first table.
www.gemechisbido.com
ERD (Entity Relationship Diagrams)

An Entity Relationship Diagram (ERD) is a visual

representation of different data using conventions that

describe how these data are related to each other. For

example, the elements writer, novel, and consumer may

be described using ER diagrams this way:

In the diagram, the elements inside rectangles are called

entities while the items inside diamonds denote the

relationships between entities.

www.gemechisbido.com
www.gemechisbido.com

ER Diagram Symbol and Notations


1) Entity: an entity can be a person, place, event, or object that is relevant to a given system. For example, a school system
may include students, teachers, major courses, subjects, fees, and other items. Entities are represented in ER diagrams by
a rectangle and named using singular nouns.
2) Attribute: is a property, trait, or characteristic of an entity, relationship, or another attribute. note that an attribute can have
its own attributes (composite attribute). Attributes are represented by oval shapes.
3) Relationship: describes how entities interact. Relationships are represented by diamond shapes and are labelled using
verbs.
4) Weak Entity: weak entity is an entity that depends on the existence of another entity. In more technical terms it can
defined as an entity that cannot be identified by its own attributes. It uses a foreign key combined with its attributed to form
the primary key.
5) Multi valued Attribute: If an attribute can have more than one value it is called a multivalued attribute.
6) Derived Attribute: An attribute based on another attribute. is found rarely in ER diagrams.

Entity Weak Entity Attribute Relationship Multivalued Attribute Weak Relationship


Elements in ER Diagrams
Components of ER
Diagram

Entity Attribute Relationship

1-1
Weak Entity Simple Attribute
Relationship
Key Attribute 1-M
Relationship M-1
Strong Entity Relationship
Derived Attribute
Composite Attribute

M-M
Relationship
Multi-valued Attribute

www.gemechisbido.com
Entity
▪ An entity can be a person, place, event, or object that is relevant to a given system.

✓ For example, a school system may include students, teachers, major courses, subjects, fees, and other
items.

▪ Entities are represented in ER diagrams by a rectangle and named using Singular Nouns.

Weak Entity
▪A weak entity is an entity that depends on the existence of another entity. n more technical terms it can
defined as an entity that cannot be identified by its own attributes.

▪ It uses a Foreign Key combined with its attributed to form the primary key.
▪ An entity like order item is a good example for this. The order item will be meaningless without an order so it
depends on the existence of order.

www.gemechisbido.com
Attribute
In relational databases, attributes are the describing characteristics or properties that define all
items pertaining to a certain category applied to all cells of a column. The rows, instead, are called
tuples, and represent data sets applied to a single entity to uniquely identify each item.

▪ An attribute is a property, trait, or characteristic of an entity, relationship, or another attribute.

▪ These are called composite attributes.

▪ Identifiers are represented by underlying the name of the attribute(s)

Note: some top-level ER diagrams do not show attributes for the sake of simplicity.

Identifier “Attributes that uniquely identify entity instances”

▪ Becomes a PK in RDS
▪ Composite identifiers are identifiers that consist of two or more attributes
▪ Identifiers are represented by underlying the name of the attribute(s)
✓ Employee (Employee_ID), student (Student_ID)
www.gemechisbido.com
▪ In those that do, however, attributes are represented by oval shapes.

Customer
Name
C_ID

Address

City Number
Relationship Symbol Street

1-to-1 relationship 1-to-M relationship M-to-M relationship

www.gemechisbido.com
Multivalued Attribute
▪ If an attribute can have more than one value it is called a multivalued attribute.
▪ It is important to note that this is different to an attribute having its own attributes.
For example a teacher entity can have multiple subject values.

Teacher Subjects

Multivalued Attribute in ER diagrams

Derived Attribute
▪ An attribute based on another attribute.
▪ This is found rarely in ER diagrams
▪ For example, for a circle the area can be derived from the radius.
Derived attribute in ER diagrams

www.gemechisbido.com
Relationship
▪ A relationship describes how entities interact.

•For example, the entity “carpenter” may be related to the entity “table” by the relationship “builds” or
“makes”.

▪ Relationships are represented by diamond shapes and are labeled using verbs.

Carpenter Makes Table

Using Relationships in Entity Relationship Diagrams

Recursive Relationship
▪ If the same entity participates more than once in a relationship it is known as a recursive relationship.

•In the below example an employee can be a supervisor and be supervised, so there is a recursive relationship.

www.gemechisbido.com
ER Diagram Templates
• Below are some ER diagram templates so you can get started quickly.

Name Dept
Entity
Relationship

M Take M
Major Student Professor Name
Class

M-to-M
Many to Many

IDNum Class
www.gemechisbido.com
Student Exam Subject
Name
No. No.

Exam Exam
Makes Exam Date
Attendees

Phone Exam Record

Record Record Card Score


No.

Subject Name
Benefit of ER Diagram
▪ Constitute a very useful framework for creating and manipulating databases.
▪ Are easy to understand and do not require a person to undergo extensive training to be able to work
with it efficiently and accurately.

▪ Designers can use ER diagrams to easily communicate with developers, customers, and end users,
regardless of their IT proficiency.

▪ Are readily translatable into relational tables which can be used to quickly build databases.
▪ Can be directly used by database developers as the blueprint for implementing data in specific
software applications.

▪ May be applied in other contexts such as describing the different relationships and operations within
an organization.
Validation Rules
Restrict data input by using validation rules
You can vet or validate data in Access desktop databases as you enter it by using validation rules. You can use the
expression builder to help you format the rule correctly. Validation rules can be set in either table design or table
datasheet view. There are three types of validation rules in Access:
1. Field Validation Rule: You can use a field validation rule to specify a criterion that all valid field values must
meet. You should not have to specify the current field as a part of the rule unless you are using the field in a
function. Restrictions on types of characters to be entered in a field may be easier to do with an Input Mask.
For example, a date field might have a validation rule that disallows values in the past.
Quick examples:
Disallow date values in the past: >=Date()
Generally accepted Email format: Is Null OR ((Like "*?@?*.?*") AND (Not Like "*[ ,;]*"))
Number less than or equal to five: <=5
Currency field can't be negative: >=0
Restrict character length in string: Len([StringFieldName])<100
Field validation rule displayed in Access table designer
www.gemechisbido.com
2. Record Validation Rule: You can use a record validation rule to specify a condition that all valid records must satisfy. You can
compare values across different fields using a record validation rule. For example, a record with two date fields might require that
values of one field always precede values of the other field (e.g., StartDate is before EndDate).
Quick examples:
Ensure the end date doesn't come before the start date: [End Date]>=[Start Date]
Enter a required date that occurs no more than 30 days after the order date: [RequiredDate]<=[OrderDate]+30
A table validation rule in the Access table designer.
3. Validation on a form: You can use the Validation Rule property of a control on a form to specify a criterion that all values input
to that control must meet. The Validation Rule control property works like a field validation rule. Typically, you use a form
validation rule instead of a field validation rule if the rule was specific only to that form and not to the table no matter where it was
used.
A validation rule is one way to restrict input in a table field or a control (such as a text box) on a form. Validation text lets you
provide a message to help users who input data that is not valid. When data is entered, Access checks to see whether the
input breaks a validation rule – if so, the input is not accepted, and Access displays a message. Access provides a number of
ways to restrict input: o Data types: Every table field has a data type that restricts what users can enter. For example, a
Date/Time field accepts only dates and times, a Currency field accepts only monetary data, and so on. o Field properties: Some
field properties restrict data input. For example, the Field Size property of a field restricts input by limiting the amount of data.
www.gemechisbido.com
You can also use the Validation Rule property to require specific values, and the Validation Text property to alert your
users to any mistakes.
❑ Input masks: You can use an input mask to validate data by forcing users to enter values in a specific way. For
example, an input mask can force users to enter dates in a European format, such as 2007.04.14.
Types of Validation Rules
You can create two basic types of validation rules:
❑ Field validation rules: Use a field validation rule to check the value that you enter in a field when you leave the
field. For example, suppose you have a Date field, and you enter >=#01/01/2010# in the Validation Rule property
of that field. Your rule now requires users to enter dates on or after January 1, 2010. If you enter a date earlier
than 2010 and then try to place the focus on another field, Access prevents you from leaving the current field until
you fix the problem.
❑ Record validation rules: Use a record validation rule to control when you can save a record (a row in a table).
Unlike a field validation rule, a record validation rule refers to other fields in the same table. You create record
validation rules when you need to check the values in one field against the values in another. You can define a
record validation rule such as [RequiredDate]<=[OrderDate]+30 to ensure that someone doesn't enter a ship
date (the value in the RequiredDate field) too far into the future.
www.gemechisbido.com
What you can put in a
Validation Rule?
Your validation rules can contain expressions functions that return a single value. You can use an expression to
perform calculations, manipulate characters, or test data. A validation rule expression tests data. For example,
an expression can check for one of a series of values, such as "Tokyo" Or "Moscow" Or "Paris" Or
"Helsinki".
Notes: The following field types do not support validation rules:
▪ AutoNumber
▪ OLE Object
▪ Attachment
▪ ReplicationID
Create a Field Validation Rule
1. Select the field that you want to validate.
2. On the Fields tab, in the Field Validation group, click Validation, and then click Field Validation Rule.
3. Use the Expression Builder to create the rule. For more information about using the Expression Builder,
see the article Use the Expression Builder.
www.gemechisbido.com
Create a message to display for field input that is not valid
1. Select the field that needs a message for input that is not valid. The field should already have a validation rule.
2. On the Fields tab, in the Field Validation group, click Validation, and then click Field Validation Message.
3. Enter an appropriate message. For example, if the validation rule is >10, the message might be “Enter a value
that is greater than 10.”
Create a record validation rule
1. Open the table for which you want to validate records.
2. On the Fields tab, in the Field Validation group, click Validation, and then click Record Validation Rule.
3. Use the Expression Builder to create the rule. For more information about using the Expression Builder, see
the article Use the Expression Builder.
Create a message to display for record input that is not valid
1. Open the table that needs a message for input that is not valid. The table should already have a record
validation rule.
2. On the Fields tab, in the Field Validation group, click Validation, and then click Record Validation Message.
3. Enter an appropriate message. For example, if the validation rule is [StartDate]<[EndDate] the message might
be “StartDate must precede EndDate.”
www.gemechisbido.com
Test existing data against a new validation rule
If you add a validation rule to an existing table, you might want to test the rule to see whether any existing data is not valid.
1. Open the table that you want to test in Design View. On the Design tab, in the Tools group, click Test Validation Rules.
2. Click Yes to close the alert message and start the test.
3. If prompted to save your table, Click Yes.
4. You might see a variety of other alert messages as you proceed. Read the instructions in each message, and then click
Yes or No, as appropriate, to complete or stop the testing.
Add a validation rule to a control on a form
You can use the Validation Rule property and the Validation Text property of a form control to validate data that is input to that
control and to help users who input data that is not valid.
Tip: If you create a form automatically from a table by using one of the Form commands on the ribbon, any validation for
fields in the underlying table are inherited by the corresponding controls on the form.
▪ A control can have a different validation rule from the table field to which the control is bound. This is useful if you want the
form to be more restrictive than the table. The form rule is applied, and then the table rule is applied. If the table is more
restrictive than the form, the rule defined for the table field takes precedence. If the rules are mutually exclusive, they
prevent you from entering any data at all.
For example, suppose you apply the following rule to a date field in a table: <#01/01/2010# But you then apply this rule to the
form control that is bound to the date field: >=#01/01/2010# www.gemechisbido.com
Create a validation rule for a control
1. Right-click the form that you want to change, and then click Layout View.
2. Right-click the control that you want to change, and then click Properties to open the property sheet for the control.
3. Click the All tab, and then enter your validation rule in the Validation Rule property box.
Tip: Click the Build button to start the Expression Builder.
4. Enter a message in the Validation Text property box.
Validation Rule Reference
Validation rules use Access expression syntax. For more information about expressions, see the article Introduction to
expressions. Validation rule and validation text examples:

Validation Rule Validation Text


<>0 Enter a nonzero value.
>=0 Value must be zero or greater.
-or- You must enter a positive number.
0 or >100 Value must be either 0 or greater than 100.
BETWEEN 0 AND 1 Enter a value with a percent sign. (For use with a field that stores number values as percentages).

<#01/01/2007# Enter a date before 2007.


>=#01/01/2007# AND <#01/01/2008# Date must occur in 2007.
<Date() Birth date cannot be in the future.
StrComp(UCase([LastName]),[LastName],0) = 0 Data in a field named LastName must be uppercase.

>=Int(Now()) Enter today's date.


M Or F Enter M for male or F for female.
LIKE "[A-Z]*@[A-Z].com" OR "[A-Z]*@[A- Enter a valid .com, .net, or .org e-mail address.
Z].net" OR "[A-Z]*@[A-Z].org"
[RequiredDate]<=[OrderDate]+30 Enter a required date that occurs no more than 30 days after the order date.

[EndDate]>=[StartDate] Enter an ending date on or after the start date.

Syntax examples for common validation rule operators

Operator Function Example


NOT Tests for converse values. Use before any comparison operator except IS NOT > 10 (the same as <=10).
NOT NULL.
IN Tests for values equal to existing members in a list. Comparison value IN
must be a comma-separated list enclosed in parentheses. ("Tokyo","Paris","Moscow")

BETWEEN Tests for a range of values. You must use two comparison values — low BETWEEN 100 AND 1000 (the same as
and high — and you must separate those values with the AND separator >=100 AND <=1000)
LIKE Matches pattern strings in Text and Memo fields. LIKE "Geo*"
www.gemechisbido.com
IS NOT NULL Forces users to enter values in the field. This is the same as setting the IS NOT NULL
Required field property to Yes. However, when you enable the Required
property and a user fails to enter a value, Access displays a somewhat
unfriendly error message. Typically, your database is easier to use if you
use IS NOT NULL and enter a friendly message in the Validation Text
property.
AND Specifies that all parts of the validation rule must be true. >= #01/01/2007# AND
<=#03/06/2008#

Note: You can also use AND to combine


validation rules. For example: NOT "UK"
AND LIKE "U*".
OR Specifies that some but not all parts of the validation rule must be true. January OR February

< Less than. <100


<= Less than or equal to. <=100
> Greater than. >18
>= Greater than or equal to. >=25
= Equal to. =10
<> Not equal to. <>0 www.gemechisbido.com
Using Wildcard Characters in
Validation Rules
You can use wildcard characters in your validation rules. Keep in mind that Access supports two sets of
wildcard characters: ANSI-89 and ANSI-92. Each of those standards uses a different set of wildcard
characters. By default, all .accdb and .mdb files use the ANSI-89 standard.

You can change the ANSI standard for a database to ANSI-92 by using the following procedure:

1. On the File tab, click Options.

2. In the Access Options dialog box, click Object Designers.

3. In the Query design section, under SQL Server Compatible Syntax (ANSI-92), select This database.

For more information about using wildcard characters and the ANSI standards for SQL, see the article Access
wildcard character reference.

www.gemechisbido.com
Create Database

www.gemechisbido.com
1

www.gemechisbido.com
1

www.gemechisbido.com
1

www.gemechisbido.com
www.gemechisbido.com
1

cc

“Right Click” on Field Name then Select “Primary Key”


Introduction to Data Types and
Field Properties
Every table in Access is made up of fields. The properties of a field describe the characteristics and behaviour of
data added to that field. A field's data type is the most important property because it determines what kind of
data the field can store. This article describes the data types and other field properties available in Access, and
includes additional information in a detailed data type reference section.
Overview
Data types can seem confusing for example, if a field's data type is Text, it can store data that consists of either
text or numerical characters. But a field whose data type is Number can store only numerical data. So, you have
to know what properties are used with each data type.
A field's data type determines many other important field qualities, such as the following:
▪ Which formats can be used with the field.
▪ The maximum size of a field value.
▪ How the field can be used in expressions.
▪ Whether the field can be indexed. www.gemechisbido.com
A field's data type can be predefined or you will select a data type depending on how you create the new
field. For example, if you create a field from the Datasheet view and:
▪ Use an existing field from another table, the data type is already defined in the template or in the
other table.
▪ Enter data in a blank column (or field), Access assigns a data type to the field based on the values
that you enter or you can assign the data type and format for the field.
▪ On the Modify Fields tab, in the Fields & Columns group, click Add Fields, Access displays a list of
data types that you can select from.
When to use which Data Type
Think of a field's data type as a set of qualities that applies to all the values that are contained in the field. For
example, values that are stored in a Text field can contain only letters, numbers, and a limited set of punctuation
characters, and a Text field can only contain a maximum of 255 characters.
Tip: Sometimes, the data in a field may appear to be one data type, but is actually another. For example, a
field may seem to contain numeric values but may actually contain text values, such as room numbers. You can
often use an expression to compare or convert values of different data types.
www.gemechisbido.com
The following tables show you the formats available for each data type and explain the effect of the formatting option.

Basic Types

Format Use to display


Text Short, alphanumeric values, such as a last name or a street address. Note, beginning in Access
2013, Text data types have been renamed to Short Text.

Number, Large Number Numeric values, such as distances. Note that there is a separate data type for currency.

Currency Monetary values.

Yes/No Yes and No values and fields that contain only one of two values.

Date/Time, Date/Time Extended Date/Time: Date and time values for the years 100 through 9999.
Date/Time Extended: Date and time values for the years 1 through 9999.

Rich Text Text or combinations of text and numbers that can be formatted using color and font controls.

Calculated Field Results of a calculation. The calculation must refer to other fields in the same table. You would
use the Expression Builder to create the calculation. Note, Calculated fields were first
introduced in Access 2010.

www.gemechisbido.com
Attachment Attached images, spreadsheet files, documents, charts, and other types of supported files to the records in your

database, similar to attaching files to e-mail messages.

Hyperlink Text or combinations of text and numbers stored as text and used as a hyperlink address.

Memo Long blocks of text. A typical use of a Memo field would be a detailed product description. Note, beginning in

Access 2013, Memo data types have been renamed to Long Text.

Lookup Displays either a list of values that is retrieved from a table or query, or a set of values that you specified when

you created the field. The Lookup Wizard starts and you can create a Lookup field. The data type of a Lookup

field is either Text or Number, depending on the choices that you make in the wizard.

Lookup fields have an additional set of field properties, which are located on the Lookup tab in the Field

Properties pane.

Note: Attachment and Calculated data types aren't available in .mdb file formats.

www.gemechisbido.com
Number
Format Use to Display

General Numbers without additional formatting exactly as it is stored.

Currency General monetary values.

Euro General monetary values stored in the EU format.

Fixed Numeric data.

Standard Numeric data with decimal.

Percentage Percentages.

Scientific Calculations.

www.gemechisbido.com
Date and Time
Format Use to Display

Short Date Display the date in a short format. Depends on your regional date and time settings. For

example, 3/14/2001 for USA.

Medium Date Display the date in medium format. For example, 3-Apr-09 for USA.

Long Date Display the date in a long format. Depends on you're the regional date and time settings. For

example, Wednesday, March 14, 2001 for USA.

Time am/pm Display the time only using a 12 hour format that will respond to changes in the regional date

and time settings.

Medium Time Display the time followed by AM/PM.

Time 24hour Display the time only using a 24 hour format that will respond to changes in the regional date

and time settings

www.gemechisbido.com
Yes/No
Data Type Use to display

Check Box A check box.

Yes/No Yes or No options

True/False True or False options.

On/Off On or Off options.

Field Size Property


After you create a field and set its data type, you can set additional field properties. The field's data type determines which other
properties that you can set. For example, you can control the size of a Text field by setting its Field Size property.
For Number and Currency fields, the Field Size property is especially important, because it determines the range of field values.
For example, a one-bit Number field can store only integers ranging from 0 to 255.
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.
Note: Text and Memo fields have variable field value sizes. For these data types, Field Size sets the maximum space available
for any one value.
www.gemechisbido.com
Data Types in Relationships
and Joins
A table relationship is an association between common fields in two tables. A relationship can be one-to-one, one-to-many,
or many-to-many.
A join is a SQL operation that combines data from two sources into one record in a query record set based on values in a
specified field that the sources have in common. A join can be an inner join, a left outer join, or a right outer join.
When you create a table relationship or add a join to a query, the fields that you connect must have the same or
compatible data types. For example, you cannot create a join between a Number field and a Text field, even if the values
in those fields match.
In a relationship or a join, fields that are set to the AutoNumber data type are compatible with fields that are set to the
Number data type if the Field Size property of the latter is Long Integer.
You cannot change the data type or the Field Size property of a field that is involved in a table relationship. You can
temporarily delete the relationship to change the Field Size property. However, if you change the data type, you won't be
able to re-create the relationship without first also changing the data type of the related field. For more information on
tables see the article, Introduction to tables.

www.gemechisbido.com
Data Type Reference
When you apply a data type to a field, it contains a set of properties that you can select.
Click on data types below for more information.
1) Attachment
2) AutoNumber
3) Calculated
4) Currency
5) Date/Time and Date/Time Extended
6) Hyperlink
7) Memo
8) Number
9) Large Number
10) OLE Object
11) Text
12) Yes/No

www.gemechisbido.com
Attachment
Purpose: Used in a field that allows attaching files or images to a record. For example, if you have a job contacts
database, you can use an attachment field to attach a photo of the contact, or attach documents such as a resume. For
some file types, Access compresses each attachment as you add it. Attachment data types are available only in .accdb file
format databases.
Types of attachments that Access compresses
When you attach any of the following file types, Access compresses the file.
▪ Bitmaps, such as .bmp files
▪ Windows Metafiles, including .emf files
▪ Exchangeable File Format files (.exif files)
▪ Icons
▪ Tagged Image File Format files
You can attach many kinds of files to a record. However, some file types that may pose security risks are blocked. As a
rule, you can attach any file that was created in one of the Microsoft Office programs. You can also attach log files (.log),
text files (.text, .txt), and compressed .zip files. For a list of supported image file formats, see the table later in this section.

www.gemechisbido.com
.ade .ins .mda .scr
.adp .isp .mdb .sct

.app .its .mde .shb

.asp .js .mdt .shs

.bas .jse .mdw .tmp

.bat .ksh .mdz .url

.cer .lnk .msc .vb

.chm .mad .msi .vbe List of Blocked File


.cmd .maf .msp .vbs
Types
.com .mag .mst .vsmacros

.cpl .mam .ops .vss ▪ Access blocks the following kinds of attached files.
.crt .maq .pcd .vst

.csh .mar .pif .vsw

.exe .mas .prf .ws

.fxp .mat .prg .wsc

.hlp .mau .pst .wsf

.hta .mav .reg .wsh

.inf .maw .scf www.gemechisbido.com


Supported Field Properties
Supported image File Formats
Access supports the following graphic file formats without the Property Use
need for additional software being installed on your computer. Caption The label text that is displayed for this
▪ Windows Bitmap (.bmp files) field by default in forms, reports, and
▪ Run Length Encoded Bitmap (.rle files) queries. If this property is empty, the

▪ Device Independent Bitmap (.dib files) name of the field is used. Any text string

▪ Graphics Interchange Format (.gif files) is allowed.


An effective caption is usually brief.
▪ Joint Photographic Experts Group (.jpe, .jpeg, and .jpg files)
▪ Exchangeable File Format (.exif files)
Required Requires that each record has at least
▪ Portable Network Graphics (.png files)
one attachment for the field.
▪ Tagged Image File Format (.tif and .tiff files)
▪ Icon (.ico and .icon files)
▪ Windows Metafile (.wmf files)
▪ Enhanced Metafile (.emf files)

www.gemechisbido.com
File Naming Conventions
www.gemechisbido.com

The names of your attached files can contain any Unicode character supported by the NTFS file system that is used in
Microsoft Windows NT. In addition, file names must follow the following guidelines:
▪ Names must not exceed 255 characters, including the file name extensions.
▪ Names cannot contain the following characters: question marks (?), quotation marks ("), forward or backward
slashes (/ \), opening or closing brackets (< >), asterisks (*), vertical bars or pipes (|), colons (:), or paragraph
marks (¶).
AutoNumber
Purpose: use an AutoNumber field to provide a unique value that serves no other purpose than to make each record
unique. The most common use for an AutoNumber field is as a primary key, especially when no suitable natural key (a
key that is based on a data field) is available.
An AutoNumber field value requires 4 or 16 bytes, depending on the value of its Field Size property.
Suppose that you have a table that stores contacts' information. You can use contact names as the primary key for that
table, but how do you handle two contacts with exactly the same name? Names are unsuitable natural keys, because
they are often not unique. If you use an AutoNumber field, each record is guaranteed to have a unique identifier.

Note: You should not use an AutoNumber field to keep a count of the records in a table. AutoNumber values are not reused, so deleted
records can result in gaps in your count. Moreover, an accurate count of records can be easily obtained by using a Totals row in a datasheet.
Field Properties

www.gemechisbido.com
Supported Field Properties
Property Use
Field Size Determines the amount of space that is allocated for each value. For AutoNumber fields, only two values are
allowed:

▪ The Long Integer field size is used for AutoNumber fields that are not used as replication IDs. This is the
default value. You should not change this value unless you are creating a replication ID field.
Note: Replication is not supported in databases that use a new file format, such as .accdb.

▪ This setting makes AutoNumber fields compatible with other Long Integer Number fields when they are used
in relationships or joins. Each field value requires 4 bytes of storage.

▪ The Replication ID field size is used for AutoNumber fields that are used as replication IDs in a database
replica. Do not use this value unless you are working in or implementing the design of a replicated
database.

▪ Each field value requires 16 bytes of storage.


New Values Determines whether AutoNumber field increments with each new value or uses random numbers. Select one of
the following:

▪ Increment Starts with the value 1 and incrementally increases by 1 for each new record.

▪ Random Starts with a random value and assigns a random value to each new record. Values are of the
Long Integer field size, and range from -2,147,483,648 to 2,147,483,647.
www.gemechisbido.com
Cont..
Format If you are using an AutoNumber field as a primary key or as a Replication ID, you should not set this property.
Otherwise, choose a number format that meets your specific needs.
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the
name of the field is used. Any text string is allowed.
An effective caption is usually brief.
Indexed Specifies whether the field has an index. There are three available values:

▪ Yes (No duplicates) Creates a unique index on the field.

▪ Yes (Duplicates OK) Creates a non-unique index on the field.

▪ No Removes any index on the field.


Note: Do not change this property for a field that is used in a primary key. Without a unique index, it is possible
to enter duplicate values, which can break any relationships in which the key is a part.
Although you can create an index on a single field by setting the Indexed field property, some kinds of indexes
cannot be created in this manner. For example, you cannot create a multi-field index by setting this property.
Smart Tags Attaches a smart tag to the field. Smart tags were deprecated in Access 2013.
Text Align Specifies the default alignment of text within a control.
Calculated
Purpose Use to store the results of a calculation.
The calculation must refer to other fields in the same table. You would use the Expression Builder to create the
calculation. Note, Calculated data types were first introduced in Access 2010. Calculated data types are available only in
.accdb file format databases.
Property Use
Expression The result of this calculation will be stored in the calculated column. If this column has been saved, then only saved
columns can be used in this expression.

Result Type The result of the calculation will be displayed as this data type.

Format Determines the way that the field appears when it is displayed or printed in datasheets or in forms or reports that are bound
to the field. You can use any valid number format. In most cases, you should set the Format value to match the result type.

Decimal Places Specifies the number of decimal places to use when displaying numbers.

Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the name of
the field is used. Any text string is allowed.
An effective caption is usually brief.

Text Align Specifies the default alignment of text within a control.


Currency
Purpose use to store monetary data.
Data in a Currency field is not rounded off during calculations. A Currency field is accurate to 15 digits to the left of the
decimal point and 4 digits to the right. Each Currency field value requires 8 bytes of storage.

Property Use
Format Determines the way that the field appears when it is displayed or printed in datasheets or in forms or reports that are bound to
the field. You can use any valid number format. In most cases, you should set the Format value to Currency.
Decimal Places Specifies the number of decimal places to use when displaying numbers.
Input Mask Displays editing characters to guide data entry. For example, an input mask might display a dollar sign ($) at the beginning of the
field.
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the name of the
field is used. Any text string is allowed. An effective caption is usually brief.
Default Value Automatically assigns the specified value to this field when a new record is added.
Validation Rule Supplies an expression that must be true whenever you add or change the value in this field. Use in conjunction with the
Validation Text property.
Validation Text Enter a message to display when a value that is entered violates the expression in the Validation Rule property.
Required Requires that data be entered in the field.
Text Align Specifies the default alignment of text within a control.
Date/Time and Date/Time Extended
Purpose use to store date and time-based data.
Property Use
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the name of the field
is used. Any text string is allowed.
An effective caption is usually brief.
Default Value Automatically assigns the specified value to this field when a new record is added.
Format Determines the way that the field appears when it is displayed or printed in datasheets, or in forms or reports that are bound to
the field. You can use a predefined format or build your own custom format.
List of predefined formats
•General Date By default, if the value is a date only, no time is displayed; if the value is a time only, no date is displayed. This
setting is a combination of the Short Date and Long Time settings.
•Examples: 1) 4/3/07 2) 05:34:00 PM 3) 4/3/07 05:34:00 PM
•Long Date Same as the Long Date setting in the regional settings of Windows. Example: Saturday, April 3, 2007.
•Medium Date Displays the date as dd-mmm-yyyy. Example: 3-Apr-2007.
•Short Date Same as the Short Date setting in the regional settings of Windows. Example: 4/3/07.
•Warning: The Short Date setting assumes that dates between 1/1/00 and 12/31/29 are twenty-first century dates (that is, the
years are assumed to be 2000 to 2029). Dates between 1/1/30 and 12/31/99 are assumed to be twentieth century dates (that is,
the years are assumed to be 1930 to 1999).
•Long Time Same as the setting on the Time tab in the regional settings of Windows. Example: 5:34:23 PM.
•Medium Time Displays the time as hours and minutes separated by the time separator character, followed by an AM/PM indicator. Example:
5:34 PM.
•Short Time Displays the time as hours and minutes separated by the time separator, by using a 24-hour clock. Example: 17:34.
Lists of components that you can use in custom formats
Type any combination of the following components to build a custom format. For example, to display the week of the year and day of the week,
type ww/w.
Important: Custom formats that are inconsistent with the date/time settings specified in Windows regional settings are ignored. For more
information on Windows regional settings, see Windows Help.
Separator components
Note: Separators are set in the regional settings of Windows.
: Time separator. For example, hh:mm | or Date separator. For example, mmm/yyyy
Any short string of characters, enclosed in quotation marks ("") Custom separator. Quotation marks are not displayed. For example, "," displays a
comma.
Date format components
d Day of the month in one or two numeric digits, as needed (1 to 31). dd Day of the month in two numeric digits (01 to 31).
ddd First three letters of the weekday (Sun to Sat). dddd Full name of the weekday (Sunday to Saturday).
w Day of the week (1 to 7). ww Week of the year (1 to 53).
m Month of the year in one or two numeric digits, as needed (1 to 12). mm Month of the year in two numeric digits (01 to 12).
mmm First three letters of the month (Jan to Dec). mmmm Full name of the month (January to December). q The quarter of the year (1 to 4).
y Number of the day of the year (1 to 366).
yy Last two digits of the year (01 to 99).
yyyy Displays all digits in a year for 0001-9999 depending on the date and time data type supported range.
Time format components
h Hour in one or two digits, as needed (0 to 23). hh Hour in two digits (00 to 23).
n Minute in one or two digits, as needed (0 to 59). nn Minute in two digits (00 to 59).
s Second in one or two digits, as needed (0 to 59). ss Second in two digits (00 to 59).
Decimal Places (Date/Time Enter a fractional precision to specify the number of digits to the right of the decimal point (1-7).
Extended only) No custom format is available.
Input Mask Displays editing characters to guide data entry. For example, an input mask might display a dollar sign ($) at the beginning
of the field.
Required Requires that data be entered in the field.
Show Date Picker Specifies whether to show the Date Picker control. Note: If you use an input mask for a Date/Time field, the Date
Picker control is unavailable regardless of how you set this property.
Smart Tags Attaches a smart tag to the field. Smart tags were deprecated in Access 2013.
Text Align Specifies the default alignment of text within a control.
Validation Rule Supplies an expression that must be true whenever you add or change the value in this field. Use in conjunction with the
Validation Text property.
Validation Text Enter a message to display when a value that is entered violates the expression in the Validation Rule property.
Hyperlink
Purpose use to store a hyperlink, such as an e-mail address or a Web site URL. A hyperlink can be a UNC path or a URL. It can store up to 2048
characters.

Property Use
Allow Zero Length Allows entry (by setting to Yes) of a zero-length string ("") in a Hyperlink, Text, or Memo field.
Append Only Determines whether to track field value changes. There are two settings:
•Yes Tracks changes. To view the field value history, right-click the field, and then click Show column history.
•No Does not track changes. Warning: Warning Setting this property to No deletes any existing field value history.
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the name
of the field is used. Any text string is allowed. An effective caption is usually brief.
Default Value Automatically assigns the specified value to this field when a new record is added.
Format Determines the way that the field appears when it is displayed or printed in datasheets or in forms or reports that are
bound to the field. You can define a custom format for a Hyperlink field.
IME Mode Controls the conversion of characters in East Asian versions of Windows.
Required Requires that data be entered in the field.
Text Align Specifies the default alignment of text within a control.
Validation Rule Supplies an expression that must be true whenever you add or change the value in this field. Use in conjunction with the
Validation Text property.
Validation Text Enter a message to display when a value that is entered violates the expression in the Validation Rule property.
Memo
Purpose use to store a block of text that is more than 255 characters long and is formatted text. Note, beginning in Access 2013 Memo data type
has been renamed to Long Text.

Property Use
Allow Zero Length Allows entry (by setting to Yes) of a zero-length string ("") in a Hyperlink, Text, or Memo field.
Append Only Determines whether to track field value changes. There are two settings:
•Yes Tracks changes. To view the field value history, right-click the field, and then click Show column history.
•No Does not track changes. Warning: Setting this property to No deletes any existing field value history.
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the name of
the field is used. Any text string is allowed. Tip: An effective caption is usually brief.
Default Value Automatically assigns the specified value to this field when a new record is added.
Format Determines the way that the field appears when it is displayed or printed in datasheets or in forms or reports that are bound
to the field. You can define a custom format for a Memo field.
IME Mode Controls the conversion of characters in East Asian versions of Windows.
Smart Tags Attaches a smart tag to the field. Smart tags were deprecated in Access 2013.
Unicode Compression Compresses text that is stored in this field when less than 4,096 characters are stored.
Validation Rule Supplies an expression that must be true whenever you add or change the value in this field. Use in conjunction with the
Validation Text property.
Validation Text Enter a message to display when a value that is entered violates the expression in the Validation Rule property.
Number
Purpose use to store a numeric value that isn't a monetary value.
If you might use the values in the field to perform a calculation, use the Number data type.

Property Use
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the name of the
field is used. Any text string is allowed. An effective caption is usually brief.
Decimal Places Specifies the number of decimal places to use when displaying numbers.
Default Value Automatically assigns the specified value to this field when a new record is added.
Field Size •Byte — Use for integers that range from 0 to 255. Storage requirement is 1 byte.
•Integer — Use for integers that range from -32,768 to 32,767. Storage requirement is 2 bytes.
•Long Integer — Use for integers that range from -2,147,483,648 to 2,147,483,647. Storage requirement is 4 bytes.
•Single Use for numeric floating point values that range from -3.4 x 1038 to 3.4 x 1038 and up to seven significant digits.
Storage requirement is 4 bytes. Double Use for numeric floating point values that range from -1.797 x 10308 to 1.797 x 10308
and up to fifteen significant digits. Storage requirement is 8 bytes. Replication ID Use for storing a globally unique identifier
required for replication. Storage requirement is 16 bytes. Note that replication is not supported using the .accdb file
format. Decimal Use for numeric values that range from -9.999... x 1027 to 9.999... x 1027. Storage requirement is 12 bytes.
Input Mask Displays editing characters to guide data entry.
Required Requires that data be entered in the field.
Validation Rule Supplies an expression that must be true whenever you add or change the value in this field.
Validation Text Enter a message to display when a value that is entered violates the expression in the Validation Rule property.
Large Number
Purpose use to store a Large numeric value that isn't a monetary value. If you might use the values in the field to perform a
calculation, use the Large Number data type.
Property Use
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the name of
the field is used. Any text string is allowed. An effective caption is usually brief.
Decimal Places Specifies the number of decimal places to use when displaying numbers.
Default Value Automatically assigns the specified value to this field when a new record is added.
Format Determines the way that the field appears when it is displayed or printed in datasheets, or in forms or reports that are
bound to the field. You can use any valid number format.
Indexed •Yes (No duplicates) Creates a unique index on the field. Yes (Duplicates OK) Creates a non-unique index on the
field. No Removes any index on the field.
Input Mask Displays editing characters to guide data entry. For example, an input mask might display a dollar sign ($) at the
beginning of the field.
Required Requires that data be entered in the field.
Text Align Specifies the default alignment of text within a control.
Validation Rule Supplies an expression that must be true whenever you add or change the value in this field. Use in conjunction with the
Validation Text property.
Validation Text Enter a message to display when a value that is entered violates the expression in the Validation Rule property.
OLE Object
▪ Purpose use to attach an OLE Object, such as a Microsoft Office Excel spreadsheet, to a record. If you want to use OLE
features, you must use the OLE Object data type.
▪ In most cases, you should use an Attachment field instead of an OLE Object field. OLE Object fields support fewer file types
than Attachment fields support. In addition, OLE Object fields do not let you attach multiple files to a single record.

Supported Field Properties

Property Use

Caption The label text that is displayed for this field by default in forms, reports, and queries. If this

property is empty, the name of the field is used. Any text string is allowed.

An effective caption is usually brief.

Required Requires that data be entered in the field.

Text Align Specifies the default alignment of text within a control.


Text
Purpose use to store up to 255 characters of text. Note, beginning in Access 2013 the Text data type has been renamed to Short Text.

Property Use
Allow Zero Length Allows entry (by setting to Yes) of a zero-length string ("") in a Hyperlink, Text, or Memo field.
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the name of
the field is used. Any text string is allowed. An effective caption is usually brief.
Default Value Automatically assigns the specified value to this field when a new record is added.
Field Size Enter a value from 1 to 255. Text fields can range from 1 to 255 characters. For larger text fields, use the Memo data type.

Format Determines the way that the field appears when it is displayed or printed in datasheets or in forms or reports that are bound
to the field. You can define a custom format for a Text field.
Indexed Specifies whether the field has an index. There are three available values:
•Yes (No duplicates) Creates a unique index on the field. Yes (Duplicates OK) Creates a non-unique index on the field.
No Removes any index on the field.

Required Requires that data be entered in the field.


Validation Rule Supplies an expression that must be true whenever you add or change the value in this field. Use in conjunction with the
Validation Text property.
Validation Text Enter a message to display when a value that is entered violates the expression in the Validation Rule property.
Yes/No
Purpose use to store a Boolean value.

Property Use
Caption The label text that is displayed for this field by default in forms, reports, and queries. If this property is empty, the name of
the field is used. Any text string is allowed.
An effective caption is usually brief.
Default Value Automatically assigns the specified value to this field when a new record is added.
Format Determines the way that the field appears when it is displayed or printed in datasheets, or in forms or reports that are
bound to the field. Select one of the following:
•True/False Displays the value as either True or False. Yes/No Displays the value as either Yes or No.
•On/Off Displays the value as either On or Off.
Indexed Specifies whether the field has an index. There are three available values:
•Yes (No duplicates) Creates a unique index on the field. Yes (Duplicates OK) Creates a non-unique index on the field.
No Removes any index on the field.

Text Align Specifies the default alignment of text within a control.


Validation Rule Supplies an expression that must be true whenever you add or change the value in this field. Use in conjunction with the
Validation Text property.
Validation Text Enter a message to display when a value that is entered violates the expression in the Validation Rule property.
1

2
1

2
1

2
1

2
1

2
1

2
1
1

2
1

2
1
1
1
1
2

3
1

2
1 3

2
4
5
3

1
2
1
1
1

2
1
1
1
Use Parameters to ask for Input
when running a Query
Understanding the Terminology
Before getting into the step-by-step below, it’s helpful to understand these terms:
❑ Parameter: is a piece of information you supply to a query right as you run it. Parameters can be used by themselves or as
part of a larger expression to form a criterion in the query. You can add parameters to any of the following types of queries:
▪ Select
▪ Crosstab
▪ Append
▪ Make-table
▪ Update
❑ Criteria: are the “filters” you add to a query to specify which items are returned when you run the query.
Create a parameter query
Creating a parameter is similar to adding a normal criterion to a query:
1.Create a select query, and then open the query in Design view.
2.In the Criteria row of the field you want to apply a parameter to, enter the text that you want to display in the parameter box,
enclosed in square brackets. For example, [Enter the start date:]
3. Repeat step 2 for each field you want to add parameters to.
When you run the query, the prompt appears without the square brackets.

Fill in the value you’re looking for, and then click OK.
You can use multiple parameters in a criterion. For example, Between
[Enter the start date:] And [Enter the end date:] will generate two prompts
when you run the query.
Specify Parameter Data Types
You can set the parameter to accept only a certain type of data. It is especially important to specify the data type for numeric,
currency, or date/time data, because then, people will see a more helpful error message if they enter the wrong type of data,
such as entering text when a currency value is expected.
Note: If a parameter is configured to accept text data, any input is interpreted as text, and no error message is displayed.
To specify the data type for parameters in a query:
1. With the query open in Design view, on the Design tab, in the Show/Hide group, click Parameters.
2. In the Query Parameters box, in the Parameter column, enter the prompt for each parameter you want to specify a data
type for. Make sure that each parameter matches the prompt that you used in the Criteria row of the query design grid.
3. In the Data Type column, select the data type for each parameter.
Add a parameter to a union query
Since you can’t view a union query in the query design grid, you’ll need to do things a little differently:
1. Open the union query in SQL view.
2. Add a WHERE clause that contains the fields you want to add parameters to.
3. If a WHERE clause already exists, check to see whether the fields you want to add parameters to are already in the
clause. If they aren’t, add them.
4. Type your parameter prompt into the where clause, for example, WHERE [StartDate] = [Enter the start date:]
Note that you need to add the same filter to each section of the query. In the picture above, the query has two sections (separated
by the UNION keyword), so the parameter needs to be added twice. When you run the query, however, the prompt only appears
once (assuming you have spelled the prompt exactly the same in each section).
Combine parameters with wildcards for more flexibility
As with normal criteria, you can combine parameters with the Like keyword and wildcard characters to match a wider range of
items. For example, you might want your query to prompt for a country/region of origin, but to match any value that contains the
parameter string. To do this:
1. Create a select query, and then open the query in Design view.
2. In the Criteria row of the field you want to add a parameter to, type Like "*"&[, the text that you want to use as a prompt,
and then ]&"*".
When you run the parameter query, the prompt appears in the dialog box without the square brackets, and without
the Like keyword or wildcard characters: After you enter the parameter, the query returns values that contain the parameter string.
Return items that don’t match the parameter
Instead of having the query return items that match your parameter, you might want the query to return items that don’t match it.
For example, you might want to prompt for a year and then return items where the year is greater than the one you entered. To do
this, type a comparison operator to the left of the first square bracket that encloses the parameter prompt, for example,>[Enter a
year:].
1
1

2
1

You can add data here in this form


2
3
4
5
6
7
8
9
c
c
Thank You
Operating Database Application
www.gemechisbido.com

You might also like