Week 3
Week 3
Definition ................................................................................................................................................................. 2
Section 1: History of Databases ............................................................................................................................. 2
Section 2: Database Management Systems ........................................................................................................... 5
Popular types of DBMSes..................................................................................................................................... 6
Relational database management system (RDMS): .......................................................................................... 7
NoSQL DBMS .................................................................................................................................................. 7
In-memory database management system (IMDBMS): ................................................................................... 7
Columnar database management system (CDBMS) ......................................................................................... 8
Cloud-based data management system ............................................................................................................. 8
Advantages of a DBMS ........................................................................................................................................ 9
Section 3: Models of Databases ............................................................................................................................ 10
Hierarchical Database Model .............................................................................................................................. 10
Network Model ................................................................................................................................................... 11
Entity Relationship Model .................................................................................................................................. 11
Object-Oriented Database Models ...................................................................................................................... 15
Relational Model................................................................................................................................................. 16
Normalization ..................................................................................................................................................... 17
Data Types .......................................................................................................................................................... 20
Big Data and Metadata ....................................................................................................................................... 21
Section 4: Creating Databases using Microsoft Access ..................................................................................... 22
Tables .................................................................................................................................................................. 22
Forms .................................................................................................................................................................. 23
Queries ................................................................................................................................................................ 23
Reports ................................................................................................................................................................ 23
Microsoft Access 2016 ....................................................................................................................................... 25
The Interface ................................................................................................................................................... 25
Object working and sorting in the Navigation pane ....................................................................................... 26
Understanding tables....................................................................................................................................... 27
Validation rules ............................................................................................................................................... 31
Working with Forms ....................................................................................................................................... 33
Subforms ......................................................................................................................................................... 36
Queries ............................................................................................................................................................ 39
Reports ............................................................................................................................................................ 50
References .............................................................................................................................................................. 61
Definition
A Database Management System is the tool that allows a person to organize, store, and retrieve data
from a computer. In other words, it is a way of communicating with a computer’s stored memory.
Databases have played a very important part in the recent evolution of computers.
Databases Definition
Databases are basically containers for data. Taking as an example a public library which stores books,
we could also say that a library is a database of books. Databases are computer structures that save,
organize, protect, and deliver data. A system that contains databases is called a database management
system, or DBM.
Early 1950s: At the time, computers were basically giant calculators and data (names, phone numbers)
was considered the leftovers of processing information. It was the time that computers were just starting
to become available to the public, and businesses, so the leftover data suddenly became important.
By the mid-1960s, because if the fast development of computers, many kinds of general database
systems became available.
This lead to Bachman forming the Database Task Group.
This group took responsibility for the design and standardization of a language called Common
Business Oriented Language (COBOL).
The Database Task Group presented this standard in 1971, which also came to be known as the
“CODASYL approach.”
The CODASYL approach was a very complicated system and required substantial training.
Searching for records could be accomplished by one of three techniques:
1. Using the primary key (also known as the CALC key)
2. Moving relationships (also called sets) to one record from another
3. Scanning all records in sequential order
In 1976: A new database model called Entity-Relationship, or ER, was proposed by P. Chen. This
model made it possible for designers to focus on data application, instead of logical table structure.
In 1980s: Structured Query Language, or SQL, became the standard query language.
Also, Relational database systems became a commercial success because of the rapid increase
in computer sales, causing a major decline in the popularity of network and hierarchical
database models.
DB2 became the main database product for IBM.
The introduction of the IBM PC at the time resulted in the establishments of many new database
companies and the development of products such as: PARADOX, RBASE 5000, RIM, Dbase
III and IV, OS/2 Database Manager, and Watcom SQL.
Early 1990s: New client tools for application development were released, including the Oracle
Developer, PowerBuilder, VB, and others. In addition, a number of tools for personal productivity, such
as ODBC and Excel/Access were developed.
Mid 1990s: The development of the Internet led to exponential growth of the database industry,
allowing the average desktop users using client-server database systems to access computer systems
that contained legacy data.
In late 1990s: the increased investment in online businesses resulted in a rise in demand for Internet
database connectors, such as Front Page, Active Server Pages, Java Servelets, Dream Weaver,
ColdFusion, Enterprise Java Beans, and Oracle Developer 2000.
The use of cgi, gcc, MySQL, Apache, and other systems brought open source solution to the
Internet.
With the increased use of point-of-sale technology, online transaction processing and online
analytic processing began to come of age.
In early 2000s: Although the Internet industry experienced a decline, database applications continue to
grow.
New interactive applications were developed for PDAs, point-of-sale transactions, and
consolidation of vendors.
Until today, the three leading database companies in the world are Microsoft, IBM, and Oracle.
XML IMDB
1995’s+ Java CMDB Mobile
Embedded
These three foundational elements help provide concurrency, security, data integrity and uniform
administration procedures.
The DBMS is useful for providing a centralized view of data that can be accessed by multiple users,
from multiple locations, in a controlled manner. A DBMS have the ability to limit what data the end
user sees, as well as how the end user can view the data, providing many views of a single database
schema.
Side Note: The term "database schema" can refer to a visual representation of a database, a set of
rules that govern a database, or to the entire set of objects belonging to a particular user.
A database schema represents the logical configuration of all or part of a relational database. It can
occur both as a visual representation and as a set of formulas known as integrity constraints that
regulate a database.
These formulas are expressed in a data definition language, such as SQL. A database schema
indicates how the entities that make up the database relate to one another, including tables, views,
stored procedures, and more.
Typically, a database designer creates a database schema to help programmers whose software will
interact with the database. The process of creating a database schema is called data modelling.
In addition, the DBMS can provide both logical and physical data independence. It can protect users
and applications from needing to know where data is stored or having to be concerned about changes to
the physical structure of data (storage and hardware). As long as programs use the application
programming interface (API) for the database that is provided by the DBMS, developers won't have to
modify programs just because changes have been made to the database.
DBMS packages generally provide an interface to view and change the design of the database, create
queries, and develop reports. Most of these packages are designed to work with a specific type of
database, but generally are compatible with a wide range of databases.
For example, Microsoft’s Access DBMS is used to work with databases in its own Microsoft Access
Database format. Microsoft Access has the ability to read and write to other database formats as well.
The most important relational database features include an ability to use tables for data storage while
maintaining and enforcing certain data relationships.
NoSQL DBMS: The NoSQL term can be applied to some databases that predated the relational
database management system (RDBMS), but it more commonly refers to the databases built in the early
2000s for the purpose of large-scale database clustering in cloud and web applications.
Accessing data in memory eliminates seek time when querying the data, which provides faster and
more predictable performance than disk.
Applications where response time is critical, such as those running telecommunications network
equipment and mobile advertising networks, often use main-memory databases.
A potential technical hurdle with in-memory data storage is the volatility of RAM. Specifically, in the
event of a power loss, intentional or otherwise, data stored in volatile RAM is lost.
The main difference between a columnar database and a traditional row-oriented database are centred
on performance, storage necessities and schema modifying techniques.
The goal of a columnar database is to efficiently write and read data to and from hard disk storage
and speed up the time it takes to return a query.
Benefits:
One of the main benefits of a columnar database is that data can be highly compressed allowing
columnar operations like: MIN, MAX, SUM, COUNT and AVG, to be performed very rapidly.
It is a self-indexing database, so it uses less disk space than a relational database management
system (RDBMS) containing the same data.
In a row-oriented database management system, the data would be stored like this:
1,Doe,John,8000;2,Smith,Jane,4000;3,Beck,Sam,1000;
In a column-oriented database management system, the data would be stored like this:
1,2,3;Doe,Smith,Beck;John,Jane,Sam;8000,4000,1000;
Cloud-based data management system: A cloud DBMS (CDBMS) is distributed database that
delivers computing as a service instead of product, which allow sharing of resources and information
between multiple devices over internet. CDBMS provide managed backup, restore and automated
scheduling you may also able to pay little or nothing for unused time.
One example of CDBMS is SaaS (software as a service), which is an application that delivers through
the browser to customers.
In addition, cloud database management system typically runs on a cloud computing platform, such as
Amazon EC2, GoGrid, Salesforce and Rackspace.
There are two methods to run a database on the cloud (just to have in mind):
1. Virtual machine
2. Database as a service
Using a DBMS to store and manage data comes with advantages, but also overhead. One of the biggest
advantages of using a DBMS is that it lets end users and application programmers access and use the
same data while managing data integrity. Data is better protected and maintained when it can be shared
using a DBMS instead of creating new iterations of the same data stored in new files for every new
application.
The DBMS provides a central store of data that can be accessed by multiple users in a controlled
manner.
Furthermore, a DBMS can also provide many views of a single database schema. A view defines what
data the user sees and how that user sees the data.
When a DBMS is used, systems can be modified much more easily when business requirements
change. New categories of data can be added to the database without disrupting the existing system and
applications can be insulated from how data is structured and stored.
In order for DBMS to provide these advantages must perform additional work, thereby bringing with it
the overhead. A DBMS will use more memory and CPU than a simple file storage system.
Different types of DBMSes will require different types and levels of system resources.
A hierarchical database model is a data model in which the data is organized into a tree-like structure.
The data is stored as records which are connected to one another through links.
A record is a collection of fields, with each field containing only one value. The entity type of a record
defines which fields the record contains.
Example of a hierarchical model a record in the hierarchical database model corresponds to a row (or
tuple) in the relational database model and an entity type corresponds to a table (or relation).
The hierarchical database model mandates that each child record has only one parent, whereas each
parent record can have one or more child records. In order to retrieve data from a hierarchical database
the whole tree needs to be traversed starting from the root node. This model is recognized as the first
database model created by IBM in the 1960s.
While the hierarchical database model structures data as a tree of records, with each record having one
parent record and many children, the network model allows each record to have multiple parent and
child records, forming a generalized graph structure.
This property applies at two levels: the schema is a generalized graph of record types connected by
relationship types (called "set types" in CODASYL), and the database itself is a generalized graph of
record occurrences connected by relationships (CODASYL "sets").
Until the early 1980s the performance benefits of the low-level navigational interfaces offered by
hierarchical and network databases were persuasive for many large-scale applications, but as hardware
became faster, the extra productivity and flexibility of the relational model led to the gradual
obsolescence of the network model in corporate enterprise usage.
An entity–relationship model (ER model) describes inter-related things of interest in a specific domain
of knowledge. Entity–relationship modeling was developed for database design by Peter Chen and
published in a 1976 paper. An ER model is composed of entity types and specifies relationships that can
exist between those entity types.
An entity–relationship model is usually the result of systematic analysis to define and describe what is
important to processes in an area of a business.
It is usually drawn in a graphical form as boxes (entities) that are connected by lines (relationships)
which express the associations and dependencies between entities.
In a simple relational database implementation, each row of a table represents one instance of an entity
type, and each field in a table represents an attribute type. In a relational database a relationship
between entities is implemented by storing the primary key of one entity as a pointer or "foreign key" in
the table of another entity.
Side Note: There is a tradition for ER/data models to be built at two or three levels of abstraction.
Conceptual data model
The conceptual ER model normally defines master reference data entities that are commonly used
by the organization. The purpose of the conceptual ER model is to establish structural metadata
commonality for the master data entities between the set of logical ER models. The conceptual data
model may be used to form commonality relationships between ER models as a basis for data model
integration.
Logical data model
A logical ER model does not require a conceptual ER model, especially if the scope of the logical
ER model includes only the development of a distinct information system. The logical ER model is
developed independently of the specific database management system into which it can be
implemented.
Physical data model
One or more physical ER models may be developed from each logical ER model. The physical ER
model is normally developed to be instantiated as a database. Therefore, each physical ER model
must contain enough detail to produce a database and each physical ER model is technology
dependent since each database management system is somewhat different.
End of Side Note
Enhanced entity–relationship
The enhanced entity–relationship (EER) model (or extended entity–relationship model) in computer
science is a high-level or conceptual data model incorporating extensions to the original entity–
relationship (ER) model, used in the design of databases.
It was developed to reflect more precisely the properties and constraints that are found in more complex
databases, such as in engineering design and manufacturing (CAD/CAM), telecommunications,
complex software systems and geographic information systems (GIS).
1. Binary Relationship
2. Recursive Relationship
3. Ternary Relationship
a. One to One:
The above example describes that one student can enroll only for one course and a course
will also have only one Student. This is not a common relationship.
b. One to Many:
The arrows in the diagram describes that one student can enroll for only one course.
c. Many to One:
The arrows in the diagram describes that Student enrolls for only one Course but a Course
can have many Students.
d. Many to Many :
The arrows in the diagram describes that Student enrolls for many Courses and many
Courses can have many Students.
2. Recursive Relationship is called when an Entity is related with itself it is known as Recursive
Relationship.
Going a little further, we have three ways or approaches of reading or analyse an E-R Diagram.
There are:
The Object-Oriented Database Management System (OODBMS) is far more abstract from other
Database models. In an OODBMS, you can store any kind of data you desire, along with the methods to
be used with that data. To retrieve this more complex and varied data, the user sends queries written in
object query language (OQL) which is an Object-Oriented Version of SQL.
As the usage of web-based technology increases with the implementation of Intranets and extranets,
companies have a vested interest in OODBMSs to display their complex data. Some object-oriented
databases are designed to work well with object-oriented programming languages such as Delphi,
Ruby, Python, Perl, Java, C#, Visual Basic .NET, C++, Objective-C, etc.
One downside is how editing an OODBMS based application is more time consuming because changes
have to be made to the other classes in the application that interact with instances of the parent class,
versus an RDBMS system where edits can typically be independent of the parent application.
o Very time consuming, that means a lot of money has to be spent on making changes to the
object-oriented database management system.
o Lack of support for security and presentation.
o Do not contain a view mechanism
o Lack of standards for the system
o There is no universal data model.
The term has generally implied a small, simple database. As computer memory has become cheaper,
more sophisticated databases can now be entirely held in memory for faster access. These newer
databases would not generally be referred to as flat-file databases.
Typical examples of flat files are /etc/passwd and /etc/group on Unix-like operating systems. A list of
names, addresses, and phone numbers written by hand on a sheet of paper is a flat file database. This
can also be done with any typewriter or word processor. A spreadsheet or text editor program may be
used to implement a flat file database, which may then be printed or used online for improved search
capabilities.
The star schema gets its name from the physical model's resemblance to a star shape with a fact table
at its centre and the dimension tables surrounding it representing the star's points. The star schema
consists of one or more fact tables referencing any number of dimension tables. The star schema is an
important special case of the snowflake schema, and is more effective for handling simpler queries.
Examples of fact data include sales price, sale quantity, and time, distance, speed, and weight
measurements. Related dimension attribute examples include product models, product colours, product
sizes, geographic locations, and salesperson name
Star schema is one of the simplest database models and is commonly used as a model for relational
data warehouses and multidimensional databases. It consists entirely of fact tables and dimension
tables.
Fact tables are an event or entity such as a sale and a dimension table consists of details about that
event such as date, place, speed of delivery, etc. For example, a geography dimension table can be used
to describe location data, such as country, state, or city.
In a star schema, a fact table is surrounded by numerous dimensions that branch out, creating an image
similar to a star.
Is compatible with Online Analytical Processing (OLAP), which allows for data mining of
specific information from different points of view. For example, a user can view the sales from
a specific item at any specific time in the past.
One of the disadvantages of the star schema model is that it is a simplistic model so it is not
capable of creating complex relational analytics. Star schemas are also denormalized so it is
possible for redundancies to occur within the database.
Relational Model
The most popular form of database today is the Relational Database (RM). A Relational Database is
one in which data is organized into one or more tables. Each table has a set of fields, which define the
nature of the data stored in the table. A record is one instance of a set of fields in a table. To understand
it better, think of the records as the rows of the table and the fields as the columns of the table. Popular
examples of relational databases are Microsoft Access, MySQL, and Oracle.
The purpose of the Relational Model is to provide a declarative method for specifying data and
queries: users directly state what information the database contains and what information they want
from it, and let the database management system software take care of describing data structures for
storing the data and retrieval procedures for answering queries.
Most relational databases use the SQL data definition and query language; these systems implement
what can be regarded as an engineering approximation to the relational model.
When designing a database, one important concept to understand is normalization. In simple terms, to
normalize a database means to design it in a way that:
Reduces duplication of data between tables,
Gives the table as much flexibility as possible (so it can be modified anytime).
In order to normalize a database, you have to understand the database anomalies. There are three types
of anomalies that occur when the database is not normalized.
These are:
1. Insertion Anomaly.
2. Update Anomaly.
3. Deletion Anomaly.
Insertion Anomaly: Suppose for a new admission, we have a Student id(S_id), name and address of a
student but if student has not Subject_opted for any subjects yet then we have to insert NULL (no
value) there, leading to Insertion Anomaly.
Updating Anomaly: To update address of a student who occurs twice or more than twice in a table, we
will have to update S_Address column in all the rows, else data will become inconsistent.
Deletion Anomaly: If S_id 401 has only one subject and temporarily he drops it, when we delete that
row, entire student record will be deleted along with it.
Normalization Rules:
So, to create a normalized database (normal forms) you have to have in mind the following
Normalization rules:
In First Normal Form, any row must not have a column in which more than one value is
saved, like separated with commas. Rather than that, we must separate such data into
multiple rows.
Using the First Normal Form, data redundancy increases, as there will be many columns
with same data in multiple rows but each row as a whole will be unique.
In Student Table the candidate key will be Student column, because all other column (for
example the Age is) dependent on it.
The New Subject Table introduced for 2NF:
In this table Student_id is Primary key, but street, city and state depends upon Zip.
The dependency between zip and other fields is called Transitive Dependency.
To apply 3NF, we need to move the street, city and state to new table, with Zip as primary key.
The New Student_Detail Table after the modification will be like this:
The New Address Table that will include the new modification will be like this:
Source: http://www.studytonight.com/dbms/database-normalization.php
Data Types
When defining the fields in a database table, we must give each field a data type. For example, the field
Birth Year is a year, so it will be a number, while First Name will be text. Most modern databases allow
for several different data types to be stored.
There are two important reasons that we must properly define the data type of a field.
1. A data type tells the database what functions can be performed with the data.
For example, if we wish to perform mathematical functions with one of the fields, we must be
sure to tell the database that the field is a number data type. So if we have, say, a field storing
birth year, we can subtract the number stored in that field from the current year to get age.
2. Is to define data type so that the proper amount of storage space is allocated for our data.
For example, if the First Name field is defined as a text (50) data type, this means fifty
characters are allocated for each first name we want to store. However, even if the first name is
only five characters long, fifty characters (bytes) will be allocated. While this may not seem like
a big deal, if our table ends up holding 50,000 names, we are allocating 50 * 50,000 = 2,500,000
bytes for storage of these values. By declaring the correct data type, it can reduce the size of the
field so we do not waste storage space.
Big Data: The term refers to such massively large data sets that conventional database tools do not
have the processing power to analyse them. For example, Walmart must process over one million
customer transactions every hour. Storing and analyzing that much data is beyond the power of
traditional database-management tools.
One of the most common applications to create databases is Microsoft Access. Microsoft Access
provides you with everything you need in order to build your own database environment.
Databases in Access are composed of four objects: tables, queries, forms, and reports. Combining these
objects allow you to enter, store, analyze, and compile data however you want.
Tables
We have to have in mind that database is a collection of data organized into many connected lists. In
Access, all data is stored in tables.
So, we can say that a record is more than just a row; it's a unit of information.
Every cell in a given row is part of that row’s record.
For example, let's say we own a coffee shop and have a database that includes a table with your
customers' names and information, like their phone numbers, home addresses, and email addresses.
Because these pieces of information are all details on your customers, you’d include them all in the
same table. Each customer would be represented by a unique record, and each type of information about
these customers would be stored in its own field. If you decided to add any more information
(customer's birthday) you would simply create a new field within the same table.
Queries
Queries are responsible in a way of searching for and compiling data from one or more tables. Running
a query is like asking a detailed question of your database. When you build a query in Access, you are
defining specific search conditions to find exactly the data you want.
However, Queries are more powerful than the simple searches you
do. While a search would be able to help you find the name of one
customer at your business, you could also run a query to find the
name and phone number of every customer who is made a
purchase within the past week. A query that design correctly can
give information you might not be able to find just by looking
through the data in your tables.
Reports
Reports offer you the ability to present your data in print. A Database
Report could be a computer printout of a class schedule or a printed
invoice of a purchase. Reports allow you to present components of
your database in an easy to read format. You can even customize a
report's appearance to make it visually appealing. Access offers you
the ability to create a report from any table or query.
Example: Electronic card catalog search. You entered your search into something that looks like this:
When you perform a search, you are entering your search terms into a form that then creating and run a
query based on your request. When the query finishes the search throw the database's tables records to
find match of your search, you were shown a report that drew information from the query and the
related tables. In this case, if a list of books is matching your search terms, you could represent the
connections between the objects like this:
The Interface
1. Quick Access Toolbar.
2. The Ribbon: The Ribbon contains all
of the commands you will need to perform
common tasks in Access.
3. Tell Me: The Tell me box works like a
search bar to help you quickly find tools or
commands you want to use.
4. Microsoft Account: From here, you
can access your Microsoft account
information, view your profile, and switch
accounts.
5. Navigation Pane: The Navigation pane
displays all of the objects contained in
your database.
6. Document Tabs Bar: All open objects are displayed in tabs on the Document Tabs bar.
7. Record Navigation Bar: The Record Navigation bar allows you to navigate records one at a time.
8. Record Search Box: You can use the Record Search box to search for any term in the current
object.
The Quick Access Toolbar is the same toolbar that exist also in Microsoft Word, Excel, and
PowerPoint. Is located above the Ribbon and lets you access common commands
no matter which tab you are on. By default, it shows the Save, Undo, and Redo
commands. If you'd like, you can customize it by adding additional commands.
By default, objects are sorted by type (tables, forms, queries and so on).
However, if you want you can sort the objects in the Navigation pane
into groups of your choosing.
When you open it, the object will appear as a tab in the
Document Tabs bar.
Select the object you want to save by clicking its tab in the Document Tabs bar.
Then, click the Save command on the Quick Access Toolbar, or press Ctrl+S
on your keyboard.
The first time you save an object, you will be prompted to name it.
Enter the desired object name, then click OK.
To close an object:
Select the object you want to close and then click the X to the right of the Document Tabs bar. You can
also close an object by right-clicking its tab on the Document Tabs bar and selecting Close. Select
Close All to close all open objects
In the Navigation pane, right-click the desired object, then select Rename.
Backstage view gives you various options for saving, opening, and printing your database.
Understanding tables
Adding records and entering data
Entering data into tables in Access is similar to entering data in Excel. To work with records, you'll
have to enter data into cells.
1. In the Records group on the Home tab, click the New command.
Delete a Record
1. Select the entire record by clicking the gray border on the left side of the record.
2. Select the Home tab and locate the Records group and Click the Delete command.
3. A dialog box will appear and Click Yes. The record will be permanently deleted.
In addition, Access offers various ways to modify the appearance of tables, including resizing fields and
rows and temporarily hiding information you don't need to see. These changes aren't just about making
your table look good but they also can make the table easier to read.
When you add a new field, you can even set the data type, which dictates which type of data can be
entered into that field.
Short Text: This is the default option and is best for most text in Access. You should also
choose it for numbers you don't plan to do math with, like postal codes and phone numbers.
Number: This is best for numbers you might want to do calculations with, like quantities of an
item ordered or sold.
To Move a field:
Locate the field you want to move, and hover your mouse over the bottom border of the field header.
When you see the cursor becoming a four-sided arrow you can Click and drag the field to its new
location. By releasing the mouse button, the field will appear in its new location.
When you set field data type, you are really setting a rule for that field. Databases often include rules
because they help ensure users enter the correct type of data.
This is important because Computers aren't as smart as humans about certain things. While you might
recognize that one and 1 or NY and New York are the same thing, Access will not and therefore won't
group these things together. Making sure to enter your data in a standard format will help you better
organize, count, and understand it.
Rules
Furthermore, by adding Rules you can also determine which options you have for working with your
data. For example, you can only do math with data entered in number or currency fields, and you can
only format text entered into text fields.
There are Three Main Types of Rules you can set for a field:
1. Data Type,
2. Character Limit,
3. Validation Rules.
Depending on the data type you chose, you may notice changes to your information. For instance, if we
set the data type for the Email field to Hyperlink all of the email addresses in the field will become
clickable links.
Validation rules
A validation rule is a rule that dictates which information can be entered into a field. When a
validation rule is in place, it is impossible for a user to enter data that violates the rule. For example, if
we were asking users to input a state name into a table with contact information, we might create a rule
that limits the valid responses to U.S. state postal codes. This would prevent users from typing
something that wasn't actually a real state postal code.
By clicking the text box, you can type your validation rule. In our
example, we want to limit data in the State field to actual state
postal codes. We will type each of the valid responses in
quotation marks and separate them with the word Or, which lets
Access know that this field can accept the response "AL" Or
"AK" Or "AZ" or any of the other terms we've entered.
Once you're satisfied with the validation rule, click OK. The
dialog box will close.
Adding calculated fields and totals rows to your table lets you perform calculations using your table
data. A calculated field calculates data within one record, while a totals row performs a calculation on
an entire field of data. Whenever you see a subtotal for one record, you are looking at a calculated field.
Similarly, whenever you see a grand total at the bottom of a table, you're looking at a totals row.
This is just as true of forms in Access. When you enter information into a form in Access, the data goes
exactly where it's supposed to go: into one or more related tables. While entering data into simple tables
is fairly straightforward, data entry becomes more complicated as you start populating tables with
records from elsewhere in the database.
For instance, the orders table in a coffee shop's database might link to information on customers,
products, and prices drawn from related tables. For example, in the Orders Table below the Customer
ID field is linked to the Customers table.
In fact, in order to see the entire order you would also have to look at the Order Items table, where the
menu items that make up each order are recorded.
As you can see, this record is much easier to understand when viewed in a form.
When you're using a form, you don't have to worry about entering data into the right tables or in the
right format, the form can handle these things itself. There's no need to go back and forth between
tables because forms bring all of the information you need together in one place.
With forms, database designers can control exactly how users are able to interact with the database.
They can even set restrictions on individual form components to ensure all of the needed data is entered
and that it's all entered in a valid format. This is useful because keeping data consistent and organized is
essential for an accurate and powerful database.
The exact procedure you use for filling out a form will vary depending on the content and design of the
form you're using.
Some forms may include more options, like calendar buttons, drop-down lists, yes/no checkboxes,
subforms, and embedded tables.
In the Navigation pane, select the table you want to use to create a form.
Then, Select the Create tab, locate the Forms group, and click the Form command.
To save the form, click the Save command on the Quick Access Toolbar. When prompted, type a name
for the form, then click OK.
Subforms
If you created a form from a table whose records are
linked to another table, your form probably includes a
subform. A subform is a datasheet form that displays
linked records in a table-like format. If you find that you
don't need a subform, you can easily delete it. To do this,
simply click it and press the Delete key on your keyboard.
When you use the Form command on an existing table, all of the fields from the table are included in
the form. However, if you later add additional fields to the table, these fields will not automatically
show up in existing forms. In situations like this, you can add additional fields to a form.
Formatting forms
Command Buttons
If you want to create a way for users of your form to quickly perform specific actions and tasks, you
can add command buttons. When you create a command button, you specify an action for it to carry out
when clicked. By including commands for common tasks right in your form, you're making the form
easier to use.
Access offers many different types of command buttons, but they can be divided into a few main
categories:
Record Navigation command buttons, which allow users to move among the records in your
database
Record Operation command buttons, which let users do things like save and print a record
Form Operation command buttons, which allow users to quickly open or close a form, print the
current form, and perform other actions
Report Operation command buttons, which offer users a quick way to do things like preview or
mail a report from the current record
In Form Layout view, select the Design tab, then locate the Controls group.
Choose the desired location for the command button, then click the mouse button.
The list in the Actions pane will update to reflect your chosen
category. Select the action you want the button to perform, then
click Next. In our example, we'll choose Find Record.
If necessary, add columns or rows to make room for the field or button you want to move by using the
Insert commands in the Rows & Columns group.
Adding logos and other images to your forms can greatly improve their appearance, as can applying
theme colors and fonts.
Queries
The real power of a relational database lies in its ability to quickly retrieve and analyze your data by
running a query. Queries allow you to pull information from one or more tables based on a set of search
conditions you define. In this lesson, you will learn how to create a simple one-table query.
Queries are a way of searching for and compiling data from one or more tables. Running a query is like
asking a detailed question of your database. When you build a query in Access, you are defining
specific search conditions to find exactly the data you want.
Queries are far more powerful than the simple searches or filters you might use to find data within a
table. This is because queries can draw their information from multiple tables. For example, while you
could use a search in the customers table to find the name of one customer at your business or a filter on
the orders table to view only orders placed within the past week, neither would let you view both
customers and orders at once. However, you could easily run a query to find the name and phone
number of every customer who's made a purchase within the past week. A well-designed query can give
information you might not be able to find out just by examining the data in your tables.
When you run a query, the results are presented to you in a table, but when you design one you use a
different view. This is called Query Design view, and it lets you see how your query is put together.
Let's familiarize ourselves with the query-building process by building the simplest query possible: a
one-table query.
We will run a query on the Customers table of our bakery database. Let's say our bakery is having a
special event, and we want to invite our customers who live nearby because they are the most likely to
come. This means we need to see a list of all customers who live close by, and only those customers.
We want to find our customers who live in the city of Raleigh, so we'll search for "Raleigh" in the City
field. Some customers who live in the suburbs live fairly close by, and we'd like to invite them as well.
We'll add their zip code, 27513, as another criteria.
If you think this sounds a little like applying a filter, you're right. A one-table query is actually just an
advanced filter applied to a table.
Access will switch to Query Design view. In the Show Table dialog box that
appears, select the table you want to run a query on. We are running a query on
our customers, so we'll select the Customers table.
The selected table will appear as a small window in the Object Relationship
pane. In the table window, double-click the field names you want to include in
your query. They will be added to the design grid in the bottom part of the
screen. In our example, we want to mail invitations to customers who live in a
certain area, so we'll include the First Name, Last Name, Street Address, City,
After you have set your criteria, run the query by clicking the Run command on the Design tab.
The query results will be displayed in the query's Datasheet view, which looks like a table. If you want,
save your query by clicking the Save command in the Quick Access Toolbar. When prompted to name
it, type the desired name, then click OK.
Planning a query
When planning a query that uses more than one table, you should go through these four steps:
1. Pinpoint exactly what you want to know. If you could ask your database any question, what
would it be? Building a query is more complicated than just asking a question, but knowing
precisely what question you want to answer is essential to building a useful query.
2. Identify every type of information you want included in your query results. Which fields contain
this information?
3. Locate the fields you want to include in your query. Which tables are they contained in?
The final thing you need to consider when designing a query is the way you link—or join—the tables
you're working with. When you add two tables to an Access query, this is what you'll see in the Object
Relationship pane:
The line connecting the two tables is called the join line.
See how the join line is actually an arrow? This is because
it indicates the order in which the query looks at data from
the two tables. In the image above, the arrow is pointing
from left to right, which means the query will look at data
in the left table first, then look at only the data in the right
table that relates to the records it's already seen in the left
table.
To understand what this means, consider the query we're designing. For our query, we need to see
customers who have placed orders, so we've included the Customers table and the Orders table. Let's
take a look at some of the data contained in these tables.
Side Note
In our query, we needed to use the right-to-left join, but the correct join direction for the tables in your
queries will depend on what information you want to see and where that information is stored. When
you add tables to a query, Access will automatically join the tables for you, but it often doesn't join
them in the correct direction. This is why it's important to always review the joins between your tables
before you build a query.
In the dialog box that appears, select each table you want to include in your query and
click Add.
You can press and hold the Ctrl key on your keyboard to select more than one table.
When we planned our query, we decided we needed information from the Customers and
Orders tables, so we'll add these.
After you have added all of the tables you want, click Close and The tables will appear in
the Object Relationship pane, linked by a join line.
By Double-clicking the thin section of the join line between two tables to edit its join
direction.
The Join Properties dialog box will appear. Select an option to choose the direction of your join. In our
example, we'll choose option 3 because we want a right-to-left join.
Set field criteria by entering the desired criteria in the criteria row of each field. We want to set two
criteria: Not in ("Raleigh") in the City field, and Like ("919*") in the Phone Number field. This will
find customers who do not live in Raleigh but who do live in the 919 area code.
After you have set your criteria, run the query by clicking the Run command on the Design tab.
The query results will be displayed in the query's Datasheet view, which looks like a table. If you want,
save your query by clicking the Save command in the Quick Access Toolbar. When prompted to name
it, type the desired name, then click OK.
Access offers several options that let you design and run queries that return exactly the information
you're looking for. For instance, what if you need to find out how many of something exists within your
database? Or what if you would like your query results to automatically be sorted a certain way? If you
know how to use query options in Access, you can design almost any query you want.
In this lesson, you'll learn how to modify and sort your queries within Query Design view, as well as
how to use the Totals function to create a query that can perform calculations with your data. You'll
also learn about additional query-building options offered in Access.
When you open an existing query in Access, it is displayed in Datasheet view, meaning you will see
your query results in a table. To modify your query, you must enter Design view, the view you used
when creating it.
On the Home tab of the Ribbon, click the View command. Select Design View from the drop-down
menu that appears.
In the bottom-right corner of your Access window, locate the small view icons. Click the Design View
icon, which is the icon farthest to the right.
Once in Design view, make the desired changes, then select the
Run command to view your updated results.
Side note: You may notice that Access also offers SQL view. You can ignore this. SQL view allows you
to create advanced functions that you will not need to use for this tutorial or for most Access functions.
Sorting queries
Access allows you to apply multiple sorts at once while you're designing your query. This allows you to
view your data exactly the way you want.
A sort that includes more than one sorted field is called a multilevel sort. A multilevel sort allows you
to apply an initial sort, then further organize data with additional sorts. For instance, if you had a table
filled with customers and their addresses, you might choose to first sort the records by city, then
alphabetically by last name.
However, we really didn't need to see this information in our final query results. In fact, if we were just
looking for customer names and addresses, seeing the order number mixed in there might have been
distracting. Fortunately, Access makes it easy to hide fields while still including any criteria they
contain.
Totals queries
Sometimes setting simple criteria won't give you the results you need, especially when you're working
with numerical values. You may want to see your query results grouped or counted in some way. For
example, let's say we want to find out how many of each menu item at our bakery has been ordered—
how many Almond Croissants, Apple Pies, and so on. To do this, we could create a totals query to find
the sum of the quantities for each item.
Count: Counts the total number of each item. Sum: Adds the values together.
Average: Finds the average of the values. Maximum: Returns the highest value.
Minimum: Returns the lowest value. First: Returns the first or earliest value.
Last: Returns the last or most recent value.
If you wanted to create a grand total for all of the items, you would need to add a totals row.
The query results will be displayed in the query's Datasheet view, which looks like a table. If you want,
save your query by clicking the Save command on the Quick Access Toolbar.
Parameter query
A parameter query allows you to create a query that can be updated easily to reflect a new criterion, or
search term. When you open a parameter query, Access will prompt you for a search term and then
show you query results that reflect that search.
A find duplicates query lets you find all duplicate records in your database so you can delete them.
Duplicate records can negatively affect the integrity of your database.
Reports
Reports give you the ability to present components of your database in an easy-to-read, printable
format. Access lets you create reports from both tables and queries.
To create a report:
It's likely that some of your data will be located on the other side of the page break. To fix this, resize
your fields. Simply select a field, then click and drag its edge until the field is the desired size. Repeat
with additional fields until all of your fields fit.
Deleting fields
You might find that your report contains some fields you don't really need to view. For instance, our
report contains the Zip Code field, which isn't necessary in a list of orders. Fortunately, you can delete
fields in reports without affecting the table or query where you grabbed your data.
While you can print reports using commands in Backstage view, you can also use Print Preview. Print
Preview shows you how your report will appear on the printed page. It also allows you to modify the
way your report is displayed, print it, and even save it as a different file type.
To print a report:
From the Home tab, click the View command, then select Print Preview from the drop-down
list. Your report will be shown as it will appear on the printed page.
If necessary, modify the page size, margin width, and page orientation using the related
commands on the Ribbon.
With Microsoft Access, you can save reports in other formats so they will be viewable outside of
Access. This is called exporting. It allows you to view or even modify reports in other formats and
programs.
To export a report:
From the Home tab, click the View command, then select Print Preview from the drop-down list.
A dialog box will appear in order to Select the location where you want to save the report.
There you can enter a name for the report file, then
click Publish.
A dialog box will appear to notify you that your file
has been successfully saved.
Click Close to return to your report.
To create a Report with Report Wizard, you have to follow the steps below:
Select the Create tab and locate the Reports group and Click the Report Wizard command.
Step 1: You have to select the fields you want to include in your report. This can be done by clicking on
the drop-down arrow and from the drop-down list you can select the table or query that contains the
desired field(s).
Then, Select a field from the list on the left, and click the right arrow to add it to the report
You can add fields from more than one table or query by repeating the above steps. Once you've added
the desired fields, click Next.
The Report Wizard will provide you with options that let you choose how to view and organize your
data. These options group similar data within your fields and organize these fields into multiple levels,
like in an outline or bulleted list.
This is valid when you are building a report from multiple tables or queries.
Fig.1 Fig.2
If you're not satisfied with the way your data is organized and want to modify them a little more, you
can do so by modifying the grouping levels.
This can be done by selecting a field from the list and clicking the right arrow to add it as a new level.
If necessary, modify the order of your grouped fields by selecting a field and clicking the up or down
Priority arrow to move it up or down a level.
Once you are satisfied with the organization of your report, click Next.
Sorting reports data is another way of modifying your reports. You can sort your report data following
the next steps:
First, Click the top drop-down arrow, and select the name of the first field you want to sort.
Then, Click the button on the right to change the sort to ascending or descending.
When you are satisfied with the way your data is sorted, click
Next.
Depending on the grouping you have chosen for your data, your
sorting options may be limited.
Click the various layout options to see how they look, then
select one to use in your report.
Once you are satisfied with your report layout, click Next.
Select the text box, and type the title you want for your report.
You may have to adjust your field and row size and location
to make sure your data looks the way you want it to. To do
this, you'll need to switch to Design view. When you're done,
switch back to Report view to see your changes.
Formatting reports
To view and modify the header and footer that appear on each page of your report, select the View
command on the Ribbon and switch to Design view. The header and footer are located in the white
space beneath the Page Header and Page Footer bars.
In case your report's design does not have a white space in the page header and footer, as in the image
below, you must resize the header and footer before you can add anything to them. You can do so by
clicking and dragging the bottom border of the header or footer to make it larger.
Select the Design tab, locate the Controls group, and click the Label command.
Every time you make a change, a preview of the text that will be
included in your report will appear.
When you are satisfied with the appearance of the date and time,
click OK.
By default, the date and time appear in the header. If you would like
to move them to the footer instead, simply click the date and time
boxes and drag them to the desired location.
The Page Numbers dialog box will appear. Under Format, choose Page N to
display the number of only the current page, or Page N of M to display the
number of the current page and the number of total pages.
Under Position, choose Top of Page or Bottom of Page to control where the page
numbers appear.
Click the drop-down arrow to select the alignment of the page numbers.
To add a logo:
A dialog box will appear. Locate and select the desired file, then click OK to add it to your report.
A small version of the image will appear in the header. Click and drag the image border to resize it. If
necessary, move your logo to the desired location by clicking and dragging it.
A theme is a set of colors and fonts that applies to the entire database to give it a consistent,
professional look. By default, databases use the Office theme. When you change the theme, all of the
theme fonts and colors in your database change to match the new theme. Designing and modifying
reports using theme elements can help you keep the appearance of your reports consistent.
Select the Design tab, locate the Themes group, and click the Themes
command.
A drop-down menu will appear. Select the desired theme. The theme
will be applied to your entire database.
Select the Design tab, locate the Themes group, and click the Fonts
command.
O'Leary, Timothy, & O'Leary, Linda, & O'Leary, Daniel. (2015). Computing Essentials, 25th Edition.
Prentice-Hall. (2010). Information Systems Today, Managing in the Digital World, fourth edition.
Prentice-Hall. (2012). Management Information Systems, twelfth edition.
Rajaraman V. (2013). Introduction to Information Technology.
Turban Efraim, & Kelly, R. R., & Richard, P. E. (2005). Introduction to Information Technology, 3rd
Edition.
Williams Brian, & Sawyer Stacey. (2015). Using Information Technology, 11th Edition.