开发者

Table with many (80+) fields or several one-to-one tables in Symfony?

I'm 开发者_StackOverflowusing Symfony1.4, so my question relates both to a database design and to Doctrine.

I have an object which has approximately 80 characteristics. Users have to fill all of them in 4 steps, so these characteristics can be divided into 4 groups. Each group will has ~20 fields. Some of them have to be required and other not.

First, I fought to create 1 main table and 3 child one-to-one tables, because in this case symfony can create different forms with database-set required field.

Then, I found this discussion. If I follow the advice to have all fields in one table, I'll have to manually create 4 different forms and control required fields.

Also I wonder, which method will be more effective in Symfony. For example, all 4 tables will be never joined - maximum 2 ot them.


Don't know about Symfony, but I'll talk from the database design perspective. If, as you have said, all 4 tables will never be joined splitting them could be a good idea depending on the queries and on the total size of the table. Users is usually a not so large table, so performance is not an issue and ease of development becomes more important. But if you are going to have several GBs of users...

Another way to reason the problem: If the association between the tables is always one-to-one (the record must be present in all of them) I would tend towards an all in one table aproach. If some of the tables could miss one record, splitting turns out to be more attractive.

You could also solve this with something like PostgreSQL hstore (or the equivalent for your RDBMS).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜