Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Database normalization

Tags:

Should I implement a read database normalization (using join tables) or should I use the ENUM type for static or dynamic data?

For example:

I have a table USER with a user_status. Should I create a table a status table or I create a ENUM list with the statuses?

Thanks G

like image 598
Gino Sullivan Avatar asked Oct 26 '11 23:10

Gino Sullivan


People also ask

What is normalization 1NF 2NF 3NF?

A relation is in 1NF if it contains an atomic value. 2NF. A relation will be in 2NF if it is in 1NF and all non-key attributes are fully functional dependent on the primary key. 3NF. A relation will be in 3NF if it is in 2NF and no transition dependency exists.

What are the four 4 types of database normalization?

First Normal Form (1 NF) Second Normal Form (2 NF) Third Normal Form (3 NF) Boyce Codd Normal Form or Fourth Normal Form ( BCNF or 4 NF)

What is normalisation in my SQL?

Normalization is the process to eliminate data redundancy and enhance data integrity in the table. Normalization also helps to organize the data in the database. It is a multi-step process that sets the data into tabular form and removes the duplicated data from the relational tables.


1 Answers

IMHO, the enum extension makes it much easier to embed semantics into a table and also improves efficiency by:

  1. decreasing the number of joins required for a query
  2. reducing the number of open tables in the DBMS

The only downsides I am aware of is

  1. the ENUM type is not implemented by other DBMS
  2. if you choose to add additional values to the ENUM set at a later date, you are applying a DDL update - which may take a long time with a very large table

HTH

C.

like image 189
symcbean Avatar answered Nov 15 '22 13:11

symcbean