[英]How distribute many columns in one table in SQL Server 2012 database
I am thinking about problem in our database. 我正在考虑数据库中的问题。
I have one table for our products. 我的产品有一张桌子。 It has few columns that it's for all products common. 它几乎没有适用于所有常见产品的列。 But products belongs to a manufacture. 但是产品属于制造商。 And each manufacture need some columns for the specification of product. 每个制造商都需要一些列来指定产品规格。 So I am thinking about distributions for our table.. 所以我在考虑我们桌子的分布。
I think that have it all in one table is waste for memory. 我认为将所有这些存储在一个表中会浪费内存。 Because for example I have 20k products for Apple and 30k for Asus, 40k for MSI.. so if I have it all in one table for columns for apple will be NULL for 70k records.. 例如,因为我有2万个产品用于Apple,而华硕则有30k,MSI有40k ..因此,如果我在一张表中将苹果的所有列全部存储为70k条记录,则为NULL。
Another idea was that I have few tables for each manufacture and in products has some key that pointing to specific table with columns for Apple.. for example key can be apple1, apple2 and so on. 另一个想法是,我每个制造商的表都很少,产品中的某些键指向Apple带有列的特定表。例如,键可以是apple1,apple2等。 But with this idea it was quite difficult to show all products with theirs specific columns. 但是有了这个主意,很难用其特定的列来显示所有产品。
So I want to ask if someone thinking about this problem in database. 所以我想问问是否有人在数据库中考虑这个问题。
I am using SQL Server 2012 for our database. 我正在为数据库使用SQL Server 2012。
Thanks for any help to this problem. 感谢您对这个问题的帮助。
Databases are built to handle information as a collection of related sets ... and to use selection criteria to get you what you want to work with. 建立数据库的目的是将信息作为一组相关的集合进行处理……并使用选择标准来获取您要使用的内容。 You should design depending on how your information elements work .. something like: 您应该根据您的信息元素的工作方式进行设计。
You can then select information for, say, Apple with something like 然后,您可以选择类似Apple的信息,例如
select xxx
from Product p, Manufacturer m
where p.manufacturerID = m.manufacturerID and m.name = "Apple"
You can use such structure... It's just example... 您可以使用这种结构...这只是示例...
If You want to compare specifications, table with product data will be more complex... 如果要比较规格,则带有产品数据的表格会更加复杂...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.