Database Management
Database Management
Database Management
A database is a collection of tables that are related to each other. Or a database allows you to store
information related to a specific topic in an organized way. Database allows you to:
1. Create and manage tables
2. Perform queries on data and create additional ones as the need arises
3. Enforce the integrity of the data
4. View reports on the data and create new ones as the need arises
NB: Access is called a relational database management program, because the tables are linked, or
related.
Table Icon
In the Customer Info table below, there are columns, or fields, of information including title and author.
Each row is a record that contains the information specific to the fields listed.
1
Table
Queries
Another database object is called a query. A query allows you to retrieve information from one or more
tables based on a set of search conditions you define using the table fields.
For example, if you want to know the name of the books that have sold in Colorado and Kansas, you could
create a query that would retrieve information from multiple tables to determine the answer. In this example,
you would retrieve information from the Order table and Books table. Queries are covered in more detail in
later lessons.
Forms
A third database object is the form. Forms are an Access tool that users can create to make data entry in
database tables easier.
Entering data directly into a table can be difficult if there is a lot of information to enter. Like an Excel
spreadsheet, an Access table is essentially a screen filled with blank rows where a user enters records.
Forms, however, provide users with an easy-to-read interface where they can enter table data. Forms are
especially useful for Access users that aren’t comfortable working with databases.
Reports
The final database object is the report. A report is an effective way to analyze and present data using a
specific layout. The text can be formatted in an Access report, just like it can be in Word documents.
To Close an Object:
● Select the tab for the object you wish to close. (The highlighted tab is the active tab).
● Right-click the tab and select Close from the menu.
Close Object
● In the dialogue box that appears, type the name of the file and choose the location where it will be
stored.
● Click create button
2
How to create you’re a table in database
● Click on the create tab of the ribbon and then click the table design button.
● Type in the fieldname and select the appropriate data type and field size. (if the a field is need for a
primary key, right-click on its row and click on primary key)
● Save the table by clicking out of the table design as the required name
NB: if you need to modify your design view; just click on table and select design view
Data Types
Data Types Purposes
Text Used to store alphanumeric characters (letters or numbers) up to 255
characters. Example include name, address, phone numbers and country
Number Used to store numbers with or without decimal places. Examples include
age, quantity and average
Currency Used to store money values. Examples includes salary, price, and
discount
Data/Time Used to store date/time types values. Examples include data of birth,
purchase date and date joined
Autonumber Creates automatic numbers, such as an ID Number
Memo Used to store blocks of text like notes up to 65536 characters long.
Examples include remarks and project details
Yes/No Used for storing a yes or no value. Examples include available and
passed
Filed Size
● Byte - used to store integers values between 0 and 255 without decimal places
● Integers – used to store integers values between -32,768 to 32,767 without decimal places.
● Long integers – used to store values between approximately -2 billion and +2 billion without any
decimal places. If you enter any values with decimal values, it will be rounded off to the next
whole number.
3
● Decimal – store numbers with decimal places
● Single – stores numbers with decimal numbers
● Double – store numbers with decimal numbers
The relationship map lists all of the tables that were selected to relate, and all of the fields that were set up
for that table previously. Notice that the first field has a key icon next to it. This is the Primary Key for the
table.
Primary Keys
A Primary Key is the first field in each table of the database. You may recall that this field auto numbers by
default, so that every record in the table has its own unique number to identify it. Access uses this number to
quickly pull information together for you when you run queries or reports, which are covered later.
In the example above, the primary key for the Customers table is Customer ID, the primary key for the
Orders table is Order ID, and the primary key for the Books table is Book ID.
A Foreign Key is a field that is the Primary Field in its own table, but that shows up in another table. If you
look closely at the Orders table, the fields Customer ID and Book ID appear there, as well as in their own
respective tables. These fields are the primary key in their own tables, but in the Orders table, they are
considered Foreign Keys.
Foreign Keys
Relating Tables
There are a few ways to establish relationships between tables:
● Using the Edit Relationships command located on the Design tab of the Ribbon
● Using the Drag and Drop method
Both methods give you the same end result, but the Drag and Drop method is much easier and saves you
several steps.
Relating Tables with the Drag and Drop Method
It is easy to relate tables from the relationship map:
● Select a field name from one table by holding down the left mouse button.
Relationship Map
● Drag the field name from the one table to the other table in the desired relationship.
● Drop the first field name onto the field name that you want to relate by releasing the left mouse button.
In the example above, we selected the Book ID field from the Books table, and dragged and dropped
it on the Book ID field in the Orders table.
4
● The Edit Relationships dialog box appears.
Access 2007 allows for several different types of relationships. These include:
● One to One
● One to Many
● Many to Many
The relationship type you will come across most frequently, and the one created in our bookstore scenario, is
the One to Many relationship.
One to Many
The One to Many relationship means that data for that field will show up a single time in one table, but
many times in the related table.
For example, let's look at one of the book titles in our bookstore. The Book ID for that book should appear
only once in the Books table, because that table lists every title that we stock. But it will probably appear
many times in the Orders table, because we hope that it gets ordered by many people many times.
The symbols for the One to Many relationship look like this:
In the Edit Relationships dialog box, an option to Enforce Referential Integrity appears.
You should click Enforce Referential Integrity to make sure that we NEVER have an order for a book that
doesn't appear in our Books table. Selecting this option tells Access to check for these things when someone
is working with your data records.
Editing Existing Relationships
Access 2007 allows you to edit relationships that already exist. This can be done using the Edit
Relationships command on the Ribbon. However, a much simpler way is to simply double click on the
link that appears in the relationship map. Either method brings up the Edit Relationships dialog box, where
you can change your settings.