Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a one column table good design? [closed]

It it ok to have a table with just one column? I know it isn't technically illegal, but is it considered poor design?

EDIT:

Here are a few examples:

  • You have a table with the 50 valid US state codes, but you have no need to store the verbose state names.
  • An email blacklist.

Someone mentioned adding a key field. The way I see it, this single column WOULD be the primary key.

like image 302
Aheho Avatar asked Jun 04 '09 16:06

Aheho


People also ask

Can a database table have only one column?

Primary keys must contain UNIQUE values, and cannot contain NULL values. A table can have only ONE primary key; and in the table, this primary key can consist of single or multiple columns (fields).

When designing a database Why is it not preferable to store all data in one table?

Answer and Explanation: Storing all data in one single table will be confusing, may have security issues and there will be duplication in recording.

What's the better database design more tables or more columns?

The usual result of these rules is that the initial design will favor tables over columns, with a focus on eliminating redundancy.

What are the characteristics of a poor database design?

Poor naming standards. Lack of documentation. One table to hold all domain values. Using identity/guid columns as your only key.


2 Answers

In terms of relational algebra this would be a unary relation, meaning "this thing exists"

Yes, it's fine to have a table defining such a relation: for instance, to define a domain.

The values of such a table should be natural primary keys of course.

A lookup table of prime numbers is what comes to my mind first.

like image 156
Quassnoi Avatar answered Oct 24 '22 23:10

Quassnoi


Yes, it's certainly good design to design a table in such a way as to make it most efficient. "Bad RDBMS Design" is usually centered around inefficiency.

However, I have found that most cases of single column design could benefit from an additional column. For example, State Codes can typically have the Full State name spelled out in a second column. Or a blacklist can have notes associated. But, if your design really does not need that information, then it's perfectly ok to have the single column.

like image 44
Erik Funkenbusch Avatar answered Oct 24 '22 23:10

Erik Funkenbusch