数据库表列有多少? [英] How many database table columns are too many?

查看:130
本文介绍了数据库表列有多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在一个拥有超过30列的用户表的项目上接管开发。不好的事情是,列的更改和添加会不断发生。

I've taken over development on a project that has a user table with over 30 columns. And the bad thing is that changes and additions to the columns keep happening.

这是不对的。

我应该把额外的字段作为值移动到第二个表中,并创建一个存储这些列名称的第三个表。

Should I push to have the extra fields moved into a second table as values and create a third table that stores those column names?

user
    id
    email

user_field
    id
    name

user_value
    id
    user_field_id
    user_id
    value


推荐答案

去键/值路由。 SQL不是处理它的,它会使数据库中的实际数据成为自我折磨的练习。 (例如:索引不能正常工作,当你必须加入才能获取加入的数据时,连接很有趣,它继续。)

Do not go the key / value route. SQL isn't designed to handle it and it'll make getting actual data out of your database an exercise in self torture. (Examples: Indexes don't work well. Joins are lots of fun when you have to join just to get the data you're joining on. It goes on.)

只要数据标准化到一个体面的水平,你没有太多的列。

As long as the data is normalized to a decent level you don't have too many columns.

编辑:要清楚,有一些问题只能是用键/值路由解决。 太多列不是其中之一。

To be clear, there are some problems that can only be solved with the key / value route. "Too many columns" isn't one of them.

这篇关于数据库表列有多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆