Sei sulla pagina 1di 13

General Information

Database normalization
Relationships in Access 2007
Create queries
Open a recently used database
Open a database through Microsoft Office Access button
Close a database

Database normalization

Database normalization is the process to organize the data of a data base. It includes the creation of
tables and the establishment of relations among them according to designed rules by eliminating the
incoherent redundancy and dependencies.

Redundancy data waste disk space and create maintenance problems. If there is to change data that
exist in more of a place, they are due to change exactly of the same form in all his locations. A change
in the direction of a client is much easier to implement if the data only store in the table Clients and not
in some other place of the data base.

Microsoft Access 2007 uses the relational model for the database management which is based on the
logic of predicates where the data is represented by mathematical n-ary relations. Each relation is
represented by the composition of fields stored in tables that represent these n-ary relations.

To transform a database in a relational database there are several normalization forms to apply:

First normal form

1) Eliminate the repeated groups of the individual tables.

2) Create an independent table for each related data set.

3) Identify each data set related with a primary key.

Second normal form

4) Create independent tables for sets of values that are applied to several records.

5) Relate these tables to an external key.

Third Normal form

6) Eliminate the fields that do not depend on the key.


Record values that are not part of the key of that record do not belong to the table. In general,
whenever the content of a group of fields can be applied to more of an only registry of the table, it
considers placing these fields in an independent table.

There are two additional normal forms (fourth and fifth) but both are rarely used.

Relationships in Access 2007

7) Open TutorialDB.

8) Click on Database Tools and select Relationships. Remember that the database must be
normalized before.

Illustration 1: Normalize the database and create relationships between tables and data.

A blank screen will appear. You must add tables.

9) Right click on the empty screen and select the Show table menu item.
Illustration 2: Normalize the database and create relationships between tables and data.

10) Add all tables in the database.

Illustration 3: All tables must be added.

11) Arrange tables in the diagram. Then click and holds the AreaId field in Areas table and drag it over
AreaId fields in Fields tables.

12) Release the mouse button to create the relationship.

Illustration 4: Edit relationships properties.


13) Edit Relationship properties and press the Create properties.

14) Repeat steps 12 and 13 to create all needed relationships.

Illustration 5: Normalized database.

Once normalized the data base, it is possible to design queries that take advantage of the relational
model.

Create Queries

Queries are those that truly make the work in a data base. They can make several different functions.
Its function commonest is to recover specific data of the tables. The data that wish to see usually are
distributed by several tables and, thanks to the queries; you can see them in a single data sheet. In
addition, since normally you do not wish to see all the records simultaneously, the queries allow you to
add criteria for "filtering" the data until obtaining the whished records. The queries often serve as origin
of registries for forms and reports.

Some queries are "updatable", which means that it is possible to edit the data of the table’s through
query’s datasheet. If it works with an updateable query, remember that the changes also take place in
the tables, no only in the query’s datasheet. There are two basic types of queries: those of selection
and those of action. A selection query simply recovers the data and causes that it become available
for his use. The results of the query can be seen in the screen, be printed or be copied to the paper
holder. Or can be used like data source for forms or reports.

An action query, as its name indicates, makes a task with the data. The action queries can serve to
create new tables, to add data to existing tables, to update data or to eliminate data.

15) Open TutorialDb.

16) Select the Create tab on Options Tape and select the Query Wizard command.

Illustration 6: Create a query.

17) Select the Simple Query wizard Option and press OK button.

Illustration 7: Simple query wizard.


Open a database through Microsoft Office Access button

18) Select the Files table from Table / Queries list. Then select Filename, Comments and
Directory fields from the Available Fields list.

Illustration 8: Configure the query’s fields.

19) Press the NEXT button.

20) Assign a name to the query.


Illustration 9: Set the query’s name. You can see the data or modify the query design.

21) Press the FINISH button. You will see the data.

Illustration 10: Query’s results.

22) Now, you will create a more refined query. Select the Create option in the Options Tape, and
select the Query design command.

Illustration 11: Query design view.

23) Double click on each table name to add it to the query designer.

Illustration 12: Query design view.

Notice that the relations between tables are added at time of there is added to the query designer

24) Double click on each Field on File table that you want to show. Skip the TypeId, AreaId and
ThemeId fields.

25) The fields Filename, Comments and Directory will appear at bottom grid. You can deselect the
show option. This option will hide the field but it will still remain in the query for other purposes (for
example, you can count the distinct instances of the file name).

Illustration 13: You added the main query fields.

26) Now, add the additional fields (those related to the TypeId, AreaId and ThemeId keys) by
clicking in AreaName from Areas table, TypeName from FileTypes table and Themename from
Themes table.

Illustration 14: You added the related table’s fields.

27) Right click on Query1 name and select the SAVE menu item.
Illustration 15: Save the query.

28) Now set a name to the query and save.

Illustration 16: Set the query name.

29) Select the Run command to view the query’s results.

Illustration 17: Run the query.

30) Access 2007 will take each related field from related tables using the relational model data retrieval
theory.

Illustration 18: Query Results.

If you try to change any related field (like AreaName, ThemeName or TypeName) all instances of
these fields will be changed. For example if you change the value “SCM” at the ThemeName in the first
row, all instances of this field will be changed automatically in the query and the base table (Themes)
will be changed too.
Illustration 19: Changing a related field will affect all instances of this field and the base table.

31) Now you will create a crosstab query. Select the Simple Query wizard Option and press OK
button.

32) Select the Crosstab Query wizard Option and press OK button.

Illustration 20: Crosstab query wizard.

33) Select the List Files table from Table / Queries list. The Both option must be selected first.
Illustration 21: You can see a design preview.

34) Press the NEXT button.

35) Select the AreaName as row to summarize and press the NEXT button.

Illustration 22: You can see a design preview.


36) Select the TypeName as column to summarize and press the NEXT button.

Illustration 23: You can see a design preview.

37) Select the Count as summarize operation and press the NEXT button.

Illustration 24: You can see a design preview.


38) Set the query name to FilesQtyByType and select the view the query Options. Press the FINISH
button.

Illustration 25: Now, you can see the query results.

Illustration 26: Query results.

Potrebbero piacerti anche