473,441 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

Normalisation

38
Hi freinds,

pls contribute any idia on;

what is the difference between two normal forms (1NF,2NF)
Dec 26 '06 #1
27 6461
r035198x
13,262 8TB
Hi freinds,

pls contribute any idia on;

what is the difference between two normal forms (1NF,2NF)
There are many equivalent definitions for normal forms. Here is a version:

1NF
Each table must have a primary key, i.e., a minimal set of attributes that can uniquely identify a record.There must be atomicity i.e each attribute must contain a single value, not a set of values.There should be no repeating groups (categories of data that would seem to be required a different number of times on different records) by defining keyed and non-keyed attributes appropriately.

2NF
The database must meet all the requirements of the 1NF. In addition, if a table has a composite key, all attributes must be related to the whole key. And, data that is redundantly duplicated across multiple rows of a table should be moved out to a separate table.
Dec 27 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
Hi freinds,

pls contribute any idia on;

what is the difference between two normal forms (1NF,2NF)
Alem

Check out the following

Mary

First Normal Form


  • Eliminate repeating groups in individual tables.
  • Create a separate table for each set of related data
  • Identify each set of related data with a primary key
Do not use multiple fields in a single table to store similar data.




Second Normal Form
  • Create separate tables for sets of values that apply to multiple records
  • Relate these tables with a foreign key
Records should not depend on anything other than a table's primary key (a compound key, if necessary). For example, consider a customer's address in an accounting system. The address is needed by the Customers table, but also by the Orders, Shipping, Invoices, Accounts Receivable, and Collections tables. Instead of storing the customer's address as a separate entry in each of these tables, store it in one place, either in the Customers table or in a separate Addresses table.
Jan 3 '07 #3
Banfa
9,065 Expert Mod 8TB
Alem, on a point of board etiquette, I notice that you title all of the threads you start with your user name (Alem). It would be better for all concerned if you could make your thread titles an short description of the problem you are having.

It will also make the experts on the board more inclined to have a look at your threads.
Jan 4 '07 #4
Banfa
9,065 Expert Mod 8TB
mmccarthy/r035198x

Are there any other normal forms. This has direct relevence to my work (where I have been designing a database for the past 6 months).

However I kind of new NF1 and NF2, seem like common sense to me (they come directly from the programming equivilent 'no magic numbers' which basically states that you should only store data in your program 1 place then you are less likely to make a mistake if you need to change it).

Got any good links to references about this subject?
Jan 4 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
mmccarthy/r035198x

Are there any other normal forms. This has direct relevence to my work (where I have been designing a database for the past 6 months).

However I kind of new NF1 and NF2, seem like common sense to me (they come directly from the programming equivilent 'no magic numbers' which basically states that you should only store data in your program 1 place then you are less likely to make a mistake if you need to change it).

Got any good links to references about this subject?
The next one is 3NF and then you have BCNF (Boyce-Codd Normal Form)

3NF
The third normal form requires that all columns in a relational table are dependent only upon the primary key. A more formal definition is:
A relational table is in third normal form (3NF) if it is already in 2NF and every non-key column is non transitively dependent upon its primary key. In other words, all nonkey attributes are functionally dependent only upon the primary key.


The process of transforming a table into 3NF is:
  1. Identify any determinants, other the primary key, and the columns they determine.
  2. Create and name a new table for each determinant and the unique columns it determines.
  3. Move the determined columns from the original table to the new table. The determinate becomes the primary key of the new table.
  4. Delete the columns you just moved from the original table except for the determinate which will serve as a foreign key.
  5. The original table may be renamed to maintain semantic meaning.
The advantage of having relational tables in 3NF is that it eliminates redundant data which in turn saves space and reduces manipulation anomalies.

BCNF

A relation is in Boyce-Codd Normal Form (BCNF) if every determinant is a candidate key. BCNF is very similar to 3NF but deals with dependencies within the primary keys.

Most relations that are in 3NF are also in BCNF. It only happens that a relation which is in 3NF is not in BCNF when:
(a) the candidate keys in the relation are composite keys (that is, they are not single attributes),
(b) there is more than one candidate key in the relation, and
(c) the keys are not disjoint, that is, some attributes in the keys are common.

The BCNF differs from the 3NF only when there are more than one candidate keys and the keys are composite and overlapping.

Although 4NF, 5NF and even 6NF do exist they are not normally referred to.

A database is said to be normalised if it is in 3NF and/or BCNF.

MAry
Jan 4 '07 #6
r035198x
13,262 8TB
The next one is 3NF and then you have BCNF (Boyce-Codd Normal Form)

3NF


The third normal form requires that all columns in a relational table are dependent only upon the primary key. A more formal definition is:


A relational table is in third normal form (3NF) if it is already in 2NF and every non-key column is non transitively dependent upon its primary key. In other words, all nonkey attributes are functionally dependent only upon the primary key.




The process of transforming a table into 3NF is:
  1. Identify any determinants, other the primary key, and the columns they determine.
  2. Create and name a new table for each determinant and the unique columns it determines.
  3. Move the determined columns from the original table to the new table. The determinate becomes the primary key of the new table.
  4. Delete the columns you just moved from the original table except for the determinate which will serve as a foreign key.
  5. The original table may be renamed to maintain semantic meaning.
The advantage of having relational tables in 3NF is that it eliminates redundant data which in turn saves space and reduces manipulation anomalies.

BCNF

A relation is in Boyce-Codd Normal Form (BCNF) if every determinant is a candidate key. BCNF is very similar to 3NF but deals with dependencies within the primary keys.

Most relations that are in 3NF are also in BCNF. It only happens that a relation which is in 3NF is not in BCNF when:
(a) the candidate keys in the relation are composite keys (that is, they are not single attributes),
(b) there is more than one candidate key in the relation, and
(c) the keys are not disjoint, that is, some attributes in the keys are common.

The BCNF differs from the 3NF only when there are more than one candidate keys and the keys are composite and overlapping.

Although 4NF, 5NF and even 6NF do exist they are not normally referred to.

A database is said to be normalised if it is in 3NF and/or BCNF.

MAry
In practice, of course, people rarely go as far as BCNF.
Jan 5 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
In practice, of course, people rarely go as far as BCNF.
We're lucky sometimes if they go as far as 3NF.

Mary
Jan 5 '07 #8
r035198x
13,262 8TB
We're lucky sometimes if they go as far as 3NF.

Mary
I thought you were the database expert?
Jan 5 '07 #9
MMcCarthy
14,534 Expert Mod 8TB
I thought you were the database expert?
I'm the one who spends half my time fixing databases that aren't fully normalised.
Jan 5 '07 #10
r035198x
13,262 8TB
I'm the one who spends half my time fixing databases that aren't fully normalised.
When I first learnt databases there was this thing that DBMSs were being judged by their degree of normalisation. Then it seemed to just dissappear. I don't blame DBMS producers that much though (naturally being a programmer). Most of the time the functionality required is usually achieved and many companies have requirements that make it impossible to fully normalize their data.
Jan 5 '07 #11
MMcCarthy
14,534 Expert Mod 8TB
When I first learnt databases there was this thing that DBMSs were being judged by their degree of normalisation. Then it seemed to just dissappear. I don't blame DBMS producers that much though (naturally being a programmer). Most of the time the functionality required is usually achieved and many companies have requirements that make it impossible to fully normalize their data.
The problem is if you don't fully normalise the data then future development is very difficult even if you can achieve the required functionality for the moment.

Although Normalisation can be difficult due to certain circumstances it's always achieveable. You just have to understand how to make some leaps in logic. Although I've come accross business requirements that make normalisation difficult I've never come accross one that made it impossible.

Mary
Jan 5 '07 #12
r035198x
13,262 8TB
The problem is if you don't fully normalise the data then future development is very difficult even if you can achieve the required functionality for the moment.

Although Normalisation can be difficult due to certain circumstances it's always achieveable. You just have to understand how to make some leaps in logic. Although I've come accross business requirements that make normalisation difficult I've never come accross one that made it impossible.

Mary
True. Most of the lack of normalisation is due to laziness on the developer's part rather than prohibitive requirements. But the time pressure sometimes ...
Jan 5 '07 #13
MMcCarthy
14,534 Expert Mod 8TB
True. Most of the lack of normalisation is due to laziness on the developer's part rather than prohibitive requirements. But the time pressure sometimes ...
I usually find spending extra time on table structure makes life so much easier when developing queries and code. It usually balances out.
Jan 5 '07 #14
r035198x
13,262 8TB
I usually find spending extra time on table structure makes life so much easier when developing queries and code. It usually balances out.
The more time one takes designing the easier it is to write the code.

So simple and elementary, yet so seldom practiced.
Jan 5 '07 #15
MMcCarthy
14,534 Expert Mod 8TB
The more time one takes designing the easier it is to write the code.

So simple and elementary, yet so seldom practiced.
I learned my lesson the hard way. Many years ago due to time constraints I didn't spend much time on the table design and ended up wasting weeks of effort on code that should have been so simple.

Now days I can do the Normalisation almost roboticaly (no pun intended) as I've done it so many times that I often don't have to think about what I'm doing.

Mary
Jan 5 '07 #16
r035198x
13,262 8TB
I learned my lesson the hard way. Many years ago due to time constraints I didn't spend much time on the table design and ended up wasting weeks of effort on code that should have been so simple.

Now days I can do the Normalisation almost roboticaly (no pun intended) as I've done it so many times that I often don't have to think about what I'm doing.

Mary
Perhaps there was no pun.

I simply stay as far away from databases as possible.
Jan 5 '07 #17
MMcCarthy
14,534 Expert Mod 8TB
Perhaps there was no pun.

I simply stay as far away from databases as possible.
Each to their own. I quite like them most of the time.

Mary
Jan 5 '07 #18
r035198x
13,262 8TB
Each to their own. I quite like them most of the time.

Mary
Unfortunately it's not always possible to stay away. Right now I'm designing tables required for the next bit of the project I'm working on.
Jan 5 '07 #19
MMcCarthy
14,534 Expert Mod 8TB
Unfortunately it's not always possible to stay away. Right now I'm designing tables required for the next bit of the project I'm working on.
Let me know if I can help.
Jan 5 '07 #20
r035198x
13,262 8TB
Let me know if I can help.
Kind of you. Almost through though. Not many foreign keys too...
Jan 5 '07 #21
Banfa
9,065 Expert Mod 8TB
3NF
The third normal form requires that all columns in a relational table are dependent only upon the primary key. A more formal definition is:
A relational table is in third normal form (3NF) if it is already in 2NF and every non-key column is non transitively dependent upon its primary key. In other words, all nonkey attributes are functionally dependent only upon the primary key.


The process of transforming a table into 3NF is:
  1. Identify any determinants, other the primary key, and the columns they determine.
  2. Create and name a new table for each determinant and the unique columns it determines.
  3. Move the determined columns from the original table to the new table. The determinate becomes the primary key of the new table.
  4. Delete the columns you just moved from the original table except for the determinate which will serve as a foreign key.
  5. The original table may be renamed to maintain semantic meaning.
The advantage of having relational tables in 3NF is that it eliminates redundant data which in turn saves space and reduces manipulation anomalies.
Any chance you can give a simple before and after example of the 3NF process?
Jan 5 '07 #22
r035198x
13,262 8TB
Any chance you can give a simple before and after example of the 3NF process?

http://www2.yk.psu.edu/~lxn/IST_210/...finitions.html
Jan 5 '07 #23
Banfa
9,065 Expert Mod 8TB
One of the big advantages of databases in the system I am working on is that I am and programming and communications specialist, I can write the code to perform the communications and put the data into the database (and read configuration changes from the database).

Once the data is in the database some else can (and is) write a user interface using a webserver to allow data retrieval and configuration changes from anywhere in the world.
Jan 5 '07 #24
MMcCarthy
14,534 Expert Mod 8TB
One of the big advantages of databases in the system I am working on is that I am and programming and communications specialist, I can write the code to perform the communications and put the data into the database (and read configuration changes from the database).

Once the data is in the database some else can (and is) write a user interface using a webserver to allow data retrieval and configuration changes from anywhere in the world.
Did you get your head around 3NF Ben?
Jan 5 '07 #25
Banfa
9,065 Expert Mod 8TB
Did you get your head around 3NF Ben?
Taking the example r035198x post of decomposing

SUPPLIER_PART (supplier_no, part_no, quantity)

SECOND (supplier_no, status, city)

into

SUPPLIER_PART (supplier_no, part_no, quantity)

SUPPLIER_CITY (supplier_no, city)

CITY_STATUS (city, status)


In this eaxmple it appears that all suppliers from the same city must have the same status, this seems an unlikely real situation and so it is not really clear what the advantage of doing this is or in what way this differed from the decomposition from 1NF to 2NF which was

FIRST (supplier_no, status, city, part_no, quantity)

to

SUPPLIER_PART (supplier_no, part_no, quantity)

SECOND (supplier_no, status, city)


This I see the point of, clearly it makes sense to keep you supplier data (status, location etc) separate from what they can/are supplying.

The BCNF is even worst as it just seems to duplicate data for no advantage and several disadvantages in the example given.


Part of the problem is that the language used in defining the NF is not clear to me so the their meaning is not properly clear.

For instance in
1NF A relation R is in first normal form (1NF) if and only if all underlying domains contain atomic values only
what does "underlying domains contain atomic values only" mean, can you give an example where this is not the case?
Jan 5 '07 #26
MMcCarthy
14,534 Expert Mod 8TB
Part of the problem is that the language used in defining the NF is not clear to me so the their meaning is not properly clear.

For instance in
1NF A relation R is in first normal form (1NF) if and only if all underlying domains contain atomic values only
what does "underlying domains contain atomic values only" mean, can you give an example where this is not the case?
Atomic in this case just means single values. No repeated values or groups should be in the table.

For example if you have a customer/Invoice system then customers have more than one invoice. The Invoices should not be put in multiple fields like Invoice1, Invoice2, etc. and should not be a group like Invoices (101, 102, 103, etc.). In this case Invoices would be moved into a table of their own with a foreign key reference to the customer table usually customerID which would be stored for each invoice.

In this eaxmple it appears that all suppliers from the same city must have the same status, this seems an unlikely real situation and so it is not really clear what the advantage of doing this is or in what way this differed from the decomposition from 1NF to 2NF which was

FIRST (supplier_no, status, city, part_no, quantity)

to

SUPPLIER_PART (supplier_no, part_no, quantity)

SECOND (supplier_no, status, city)
supplier_no would have city and status attached to it as the city and status (I assume) are attributes of the supplier. If there is a separate supplier table then they belong there. However, if city and status are attributes that belong to the supplier_part then assuming there is more than one supplier per part you would need three tables here. One for supplier, one for part and one for supplier_part (As I don't know the rest of your structure you may already have the first two of these).

The supplier table would be a list of suppliers with all attributes belonging to suppliers. e.g. supplier_no, Address, ContactName, ContactNum, etc. The parts table would be a list of parts with e.g. part_no, cost, etc.

The supplier_part table would be supplier_no, part_no (which together would make up the primary key).

Assuming quantity is an order reference this would belong in a separate orders table.

Unfortunately, some of these example sites are not just confusing they can also be misleading with the examples being used.

All 3NF really means is that all fields (attributes) should be dependent on the tables primary key. If they are not they should be put in their own table.

BCNF in it's simplist terms just says don't have a primary key made up of more than one field unless it is a join table to disperse a many to many relationship and only contains the two primary keys of the tables it is joining.
Jan 5 '07 #27
if you need a guide, or even assistance to normalise, email me at <email address snipped>
Feb 15 '07 #28

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Michael Lauzon | last post by:
Database Normalisation Advisor Designated Contact: thox, xpl2 Status: Open Open Date: 2004-10-26 11:53 For Project: Lands of Myths & Legends (http://sourceforge.net/projects/lamyle/) Long...
1
by: Michael Lauzon | last post by:
Database Normalisation Advisor Designated Contact: thox, xpl2 Status: Open Open Date: 2004-10-26 11:53 For Project: Lands of Myths & Legends (http://sourceforge.net/projects/lamyle/) Long...
0
by: Michael Lauzon | last post by:
Database Normalisation Advisor Designated Contact: thox, xpl2 Status: Open Open Date: 2004-10-26 11:53 For Project: Lands of Myths & Legends (http://sourceforge.net/projects/lamyle/) Long...
2
by: David Allison | last post by:
Should Lookup fields be replaced by table normalisation? Then the Tables brought together in a Query for a Form to be based on? -- Dave Allison ~ Scotland
2
by: James W. | last post by:
Hi everyone, I would like to ask you lot if you know of a great place on the internet for a fool proof idiots guide to Normalisation 1st, 2nd, 3rd. I looked at webopedia but that is just as...
11
by: Michael Thomas | last post by:
Hi everyone Not sure if this is the right newsgroup to be posting to for this question, but I am using Access 2002 to develop a database solution for the company that I work for. It's basically...
3
by: Macbane | last post by:
Hello All, This has been bugging me for too long. I have a database that records medical interventions. I am familiar with the theory behind normalisation but am unsure what to do with the...
1
by: shauna | last post by:
hi, i am an As level student studying Applied ICT, im having problems with normalisation. our problem is to computerise a made up business.mine for example is a beauty salon. below are my...
2
by: hiyamwah | last post by:
Hi i am a little unsure of how you do this problem: A company wishes to allocate staff to a new project that as been proposed by the company. As a result, a new relation was created for this...
2
mikek12004
by: mikek12004 | last post by:
I have a table for categories (id->the primary key, and name) and I want to add another column parent (one category might be inside another) with the id's range of values so in fact parent will be a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.