Nipuna Chandimal
Nipuna Chandimal

Reputation: 77

Normalization and primary keys

In a given table if there is no primary key and even impossible to create a composite primary key then what is the normal form of that table ?

If its zero(0NF) adding a new column and making it primary key will convert this table to 1NF ?

Upvotes: 1

Views: 3012

Answers (4)

Walter Mitty
Walter Mitty

Reputation: 18950

As long as you are talking about tables, there is one further case that needs to be covered. It's the case of duplicate rows.

Duplicate rows are rows that are identical in appearance but not in row number. Such a table cannot have a primary key. Sometimes duplicate rows represent the same information. Sometimes not.

For example, consider a table with just four columns: customerid, productid, quentity, price. If a customer orders the same product twice, we'll have two identical rows, representing different inforation. Ths is not good.

Note that the corresonding thing cannot happen with relations. If two tuples in a relation have the same appearance, then they are the same tuple.

As to the other points, they are covered by excellent earlier answers.

Upvotes: 1

Suman Tiwari
Suman Tiwari

Reputation: 40

Answer of Question 1 : In a given table if there is no primary key and even impossible to create a composite primary key then what is the normal form of that table ?

Answer : If it is no primary key in relation and if it is impossible to create a composite primiary key(According to me your question says ,even if combine all the column of row to make candidate key then also it will not able to identify your relationship uniquly(duplicate rows are there), hence it is not in any normal form.

Answer of Question 2: If you add some column(having unique values in it) and if all the cell contains only one value then it is in 1NF.

Still if you need some clarification can ask in comment box. 0NF is not any form of normalization. refer C.J. Date or Henry korth(database management system book) Hope this helps.

Upvotes: 0

reaanb
reaanb

Reputation: 10084

Normal forms apply to relations, which are mathematical structures. Tables can be used to represent relations, but this requires some rules to ensure that the table doesn't contain more or less information than the corresponding relation.

In order for a table to represent a relation:

  • all rows and columns must be unique
  • the order they're in mustn't matter
  • all significant information must be represented as values in cells (i.e. fonts, highlighting, etc, mustn't matter)
  • every cell must contain one value (doesn't matter how simple or complex that value is)

Also, the relational model cares about candidate keys, not primary keys. A relation can have multiple candidate keys. A primary key is just a selected candidate key that is used by some disciplines (e.g. the entity-relationship model) or by some database management systems (e.g. for physical record ordering).

With all that said, I can now answer your question. If your table follows the rules and specifically the rows are all unique, then there will be at least one candidate key, on all the columns together at worst. If your table's rows aren't unique, then the table doesn't represent a relation and the normal forms don't apply. A surrogate key (like an auto-increment column) can be added to identify rows uniquely, but that isn't necessarily sufficient on its own to make a table represent a relation (1NF).

BTW, I suggest you avoid using "0NF" or "UNF". Non-relational tables don't have a level of normalization, so attaching any kind of "NF" to them is misleading.

Upvotes: 6

Milad Nourizade
Milad Nourizade

Reputation: 471

before you wan to check for normalization your table must have a Primary key(the primary key is playing lead role in Relational DB,...).

1NF: says that all of your table attributes must be single valued.

Upvotes: 0

Related Questions