Pergunta

How can denormalize this to 1NF.

    --------------------------------------------------
    |         |         |              |             |
    |         V         V              V             V
-----------------------------------------------------------
|post_id|post_title|post_text|post_submited_time|user_name|
-----------------------------------------------------------


    ------------------------------------------------
    |            |                 |               |           
    |            V                 V               V           
---------------------------------------------------------
|comment_id|comment_text|comment_submited_time|user_name|
---------------------------------------------------------

   -----------
   |         |
   |         V
--------------------
|post_id|comment_id|
--------------------

I want to one table in one normal form that when I normalize that result was up tables.

Foi útil?

Solução

It depends on the database you are using, because there are databases like postgresql that can have arrays or complex dataobjects as datatype in their columns. It normally comes with a price: you can not index nor organize this data. Then might it for instance become difficult to find out which comments an user has given on which posts. If you take a look at your own Stackoverflow.com profile, then will you see the benefit of keeping this information separated.

You can remove one table however. If you create a foreign key to the post_id in the comments-table then will you have one table less in your design yet you can make use of indices just as you need.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top