Normalizing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I make sure a table is noramlized? I have one table with a project
name, number, and funding; I have another table with each project (some list
twice due to duffering data int following fields: notes, concept, strategy,
etc.); I have a third table with customers (mulitple customers for each
project); and a fourth table with dates and notes of each time each customer
was contacted. Each table has the project name listed so that there is a
way to tie each customer to acertain project.....and so on. Does this sound
normailized? Please help!!!
 
Hi, Brandie.

First an “academic†definition of the most important “Normal Formsâ€,
paraphrased from Litwin, Getz, and Gilbert’s “Access 97 Developer’s Handbookâ€:

First Normal Form

Table Features:
- Describe one entity
- Have no duplicate rows; i.e., each has a primary key
- Columns and rows are unordered
- Column values are atomic, i.e., consist of a single value not a list of
values

Second Normal Form
- All tables are in 1st NF
- Every non-key column is dependent on the primary key

That is, each table stores data relating to one “thing†(e.g., Customers,
Orders, etc.) and the thing is fully described by its entire primary key.
Frequently, non-2NF tables are resolved by decomposing them into 2 tables,
and brought back together using a query.

Third Normal Form
- All tables are in 2nd NF
- All non-key columns are mutually independent

For example, a frequent error of new users is storing a calculated field.
For example, if you have Qty and PerItemCost fields, you could store a
TotalCost (equal to Qty*PerItemCost), but it would then not be in 3NF.
Again, the way to resolve this is with a query which calculates this total
“on the flyâ€.

There are higher order normal forms of diminishing value.

On a more practical level, when I’m designing a data base, I think first in
terms of “thingsâ€â€”Customers, Projects, etc. I give each table a primary key,
which I and many other developers prefer to be a single AutoNumber key. Then
I flesh out the attributes that describe each thing, which become
fields—CustomerName, Address, City, State, etc.

The only field that should be duplicated in a second table is another
table’s primary key, called a “foreign†key in the second table. For
example, an Orders table would contain a CustomerID field to identify the
customer, but not the CustomerName, Address, etc. fields. Those attributes
are already fully and correctly described in Customers table record that has
that CustomerID.

You can think of this foreign key has “opening†or giving you “Access†to
all of the fields in the Customers table via a query that links the two
tables into a single recordset for printing in a report, displaying on a
form, etc.

Next, I think in terms of relationships between the "things". There are
three—one-to-one, one-to-many, and many-to-many. Your two projects tables
(the one that has funding information and the one with Notes, Concept, and
Strategy) are in a one-to-one relationship. Each describe attributes of a
single project.

When you have a one-to-one relationship, 99% of the time, you can simply add
the fields from one into the other table, since they simply describe other
attributes of the same “thingâ€. Cases for splitting this information into
two tables generally relate to the need for different security level access
to different fields--to give, say, only Human Resources access to an
employee's Salary or Health information, while enabling everyone to see an
employee's name, picture, extension, title, etc.

One to many relationships are the most common—many orders for a single
customer, many order line items for a single order, etc. These are
implemented by including the primary key of the One side as a foreign key in
the many side.

Many-to-many relationships (many customers can order the same product, many
products can be purchased by the same customer) cannot be implemented
directly, but rather by two one-to-many relationships.

Because you have the ProjectName in each table and for other reasons, your
application is currently not normalized. To correct this, I see the
following tables:

Customers
CustomerID AutoNumber Primary Key (PK)
CustomerName Text
Address Text
City Text
State Text
…other Customer attributes

Projects
ProjectNumber AutoNumber or Number (PK)
ProjectName Text
Funding Text
Notes Text or Memo
Concept Text or Memo
Strategy Text or Memo

Because there is a many-to-many relationship between Customers and Projects,
you need an intermediate table to represent it, which is in a one-to-many
relationship with both Customers and Projects.

ProjectCustomers
ProjectCustomerID Autonumber (PK)
ProjectNumber Number (Foreign Key to Projects)
CustomerID Number (Foreign Key to Customers)

So you could have a main form based on Projects which showed its main data,
and a subform based on a query joining ProjectCustomers to Customers, in
order to show the CustomerName, phone number, etc. on the subform.

For the contacts, its implementation differs depending on whether you want
to show any contact with a given customer, or to show contact for a given
customer on a given project.

To show any contact, Customers and Contacts would be in a one-to-many
relationship, and so can be implemented with a main form based on Customers
with an embedded continuous subform based on Contacts, linked on the
CustomerID.

Contacts
ContactID AutoNumber (PK)
CustomerID Number (FK to Customers)
ContactDate Date/Time
ContactTime Date/Time
Notes Text or Memo

If you want to associate the contact with the customer AND the project, then
Contacts is the many side of a one-to-many relationship with
ProjectCustomers. This is a similar relationship to the
Customer->Orders->OrderItems relationship in the sample Northwind database
that can be accessed via the Help menu. One way to implement the Contacts
would be by a main form based on a query joining the ProjectCustomers,
Projects, and Customers tables, with a continuous subform based on Contacts:

Contacts
ContactID AutoNumber (PK)
ProjCustID Number (FK to ProjectCustomers)
ContactDate Date/Time
ContactTime Date/Time
Notes Text or Memo

I hope that helps.
Sprinks
 
Wow, lots of information, very helpfull. So basically any htime a field may
have more than one piece of data, I have to make a separate table and link
them somehow right?
 
Brandie,

If you're saying that the field might have many values related to the same
record, such as orders related to a customer, then, yes--implement the
one-to-many relationship with another table. Include the main table's
primary key as a foreign key in the second table.

For example, in your application, let's say you have the following project:

ProjectID: 12345
ProjectName: Normalizing My Access Application
Strategy: Consult Access Forum. Buy Litwin/Getz/Gilbert.
Etc...

You wouldn't have a field in Projects named Customers where you'd enter
4123, 3425, 2534 (hypothetical CustomerID's). You need the ProjectCustomers
table to implement this one-to-many. There will be multiple associated
records:

ProjectCustomerID ProjectID CustomerID
23 12345 4123
38 12345 3425
99 12345 2534

You also have to use your judgement. For example, hypothetically, your
Strategy memo field might actually contain multiple strategies, but it's
probably not necessary to complicate your application by breaking this memo
field up, unless each Strategy had a different manager, timetable, funding,
etc., that you wanted to track separately.

Hope that helps.
Sprinks
 
Is is OK if there are five tables and they all have the same foreign key?
Please say yes, it would make things much easier. And....Does each table
have to ahve its own primary key or is the foreign key enough?
 
Hi, Brandie.

I'm not sure you've totally grasped normalization. Don't worry; it takes a
while for the light to come on--it sure did with me.

Each table should have its OWN primary key which uniquely identifies each
record. If it is a table on the many side of a one-to-many relationship, it
should have a foreign key that corresponds in type and data to the primary
key of the table on the One side.

If you have specific questions about your tables, please post the table
structures and their relationships, and I'll be happy to help.

Sprinks
 
Table 1:

Project Number
Project Name (Primary key)
Funding

Actually I am so confused...I dont even know where to start because i know
this is wrong. Here's the deal.....The first table is what I have, for sure,
the other four just make me more confused because i cant figure out how to
conect them all. Table 2:One project has two amounts on 'funding spent'
feild, along with different notes and strategy and so on. But another project
could possibly have the same amount spent. I was going to use the 'Funding
Spent" field as my primary key but then i realized that it could be the same
for multiple projects. Table 3:Each project also has multiple customer
organizations, but each organization could be working on more than one of the
projects. Table 4:And I need to record each date they were contacted with a
notes field related to that date. Each organization has multiple dates
contacted. Table 5:And last but not least, there are muliple lines of
business for each project but those lines of business can also be the same
for another project. And each line of business can have multple points of
contacts; and each point of contact can be assigned to multple lines of
business as well as multiple projects. (...I think I'm gonna cry!...) I
hope i didn't make you confused in the process of explaining this but I hope
you can figure it out. I'll owe you one.
 
Brandie,

I know that database development, particularly defining complex requirements
can be confusing, particularly at first. Hang in there; it will be rewarding
when it’s done!

First a few questions to clarify your requirements:

- What is meant by a project having “multiple lines of business� Are these
customers for a product that will develop from the project? Or stakeholders
or supporters of the project? What is their role? Please give some
examples, and how you will use this information.
- Are Notes and Strategy related to the Funding Spent field, i.e., there is
a different strategy and notes related to the funding?
- How are the “points of contact†related to the “line of business� Are
they an employee of the line of business, or a point of contact within your
organization?
- Please describe, in generic terms, the types of tasks you will perform
when the database is up and running. For example:

o Enter a new project
o Enter a new line of business for an existing project
o Print a contact history report for a specific line of business for a
specific project

Secondly, a note about primary keys. It seems that you’re concerned about
which field to make your primary key. The truth is, a primary key needn’t
be, and *never* is, in my applications, an important functional field—it need
merely be a unique identifier for each record.

Access indexes your records by the primary key so that it can retrieve a
given record quickly. A number is more quickly read from disk than text, so
a numeric primary key is superior to a text one.

The most convenient primary key is an AutoNumber field, because Access then
takes on the role of assigning the unique identifier to each record, freeing
you, as the developer, from writing code to assist your users when they
inadvertently enter a duplicate key, and get a cryptic message from Access
stating that it “can’t add this record because doing so would create a
duplicate record…â€

In the case of your project table, you *could* use the ProjectNumber as the
primary key, assuming that it is really a number, not something like 501123A,
for example, and that it doesn’t have any leading zeros, which Access will
trim off. But really, it’s not worth worrying about—just add an AutoNumber
field called, say, ProjectID, and be done with it. You don’t have to display
this field on any form, and your users may never even know it exists. You
will use, it, however, in defining your table relationships, linking tables
in queries, and linking subforms to a main form.

One reason new users are often concerned about the primary key is that
they’d like their records to display in their forms in a certain order. No
problem, just base your forms on a query that sorts the records in the
desired order.

Thirdly, a note on development strategy. Once the tables and relationships
are defined, you will move on to creating your form(s). While it may
eventually be possible to do all of your database requirements from a single,
complex form, I strongly urge you to isolate single or related groups of
tasks and create a form for each. Get one working the way you want before
moving on. When you’ve accounted for all the tasks, live with it a while.
Make sure it works correctly and serves your needs.

Later on, you may see opportunities to consolidate some tasks to a single
form. This may be worth the effort, and it may not. In any case, climb a
series of small hills before trying the mountain.

Will look forward to your response.

Sprinks
 
It's kinda hard for me to give specific details...it's proprietary
information for my company. Let me see if I can put this into some other
business.
- I guess the line of business could be the different areas of the company
that work together on the project and the point of contact would be the
person to reach in each of them. I'm not quite sure what there role is I
just know that each project can more than one, or perhaps the same one
duplicated due to the amont of funding spent. The funding spent is basically
reffering to how much of the total funding on what.
-Notes and Strategy are related to the funding spent field. If the funding
was split for for different aspects of the project then there will be
separate notes and strategy for each part.
-When (and if) the database gets finished I wil need to enter data to
existing projects, create new projects, and look up information about the
project such as the customer information, Notes, etc. Possible Fields used
to look up information would be the project number or name, the line of
business, line of business contact, or the total amount funded for the
project.

Hope this helps you help me. =)
 
Back
Top