English 中文(简体)
数据库设计:浏览量和表格数量之多?
原标题:Database design: lots of rows vs lots of tables?

采用这一数据库设计的I m需要将一些可变的长度阵列储存到我的仪表数据库。

这些阵列的长度将(最多)在数以百计(如果不是数千)。

新阵列将定期建立,可能每天10个。

  1. should I store these arrays into one table that will soon grow gigantic or
  2. create a new table for each array and soon have a huge number or tables?
  3. something else? (like formatted text column for the array values)

澄清 1. 大致情况

CREATE TABLE array (id INT, valuetype VARCHAR(64), ...)
CREATE TABLE arr_values (id INT, val DOUBLE, FK array_id)

页: 1

CREATE TABLE array (id INT, valuetype VARCHAR(64),...)
CREATE TABLE arr_values (id int, val DOUBLE, FK array_id) -- template table
CREATE TABLE arr1_values LIKE arr_values ...

The arr_values will be used as arrays that is queried by joining to a complete array. Any ideas on why some approach is better than other?

最佳回答

与所有这些问题的答案一样,它总是取决于您的最终结果,但我个人总是赞成在充满活力的表格上单列一席——这使问题更加简单。 在你看数据库图象时,该表也更加简单(我认为),成千上万的表格可能会发现你在直接查阅数据库时需要做些什么。

此外,如果你认为有必要在某个时候把你的阵列扩大到另一个领域,这意味着将有一个单一的数据库表来改变,而不是改变许多数据库。

问题回答

几张表格中的浏览量。 为每个新结构/记录提供新的表格绝对不正确,是使用关系数据库的最坏方式。

事实上,几乎在贵国法典充满活力地制造桌子的时候,你正在做一些可怕的错误。

It looks to me like each array of data has a distinct schema. Have you considered using a NoSQL database? It will be much easier to work with, in my opinion.

如果你必须坚持我的SQL,那么你当然要尽量少表。 根据您的介绍,你可以有一个表格,分为三栏:

array ;connects all the related records to the correct array
field ;the name of the field (array key)
value ;the actual value for that field

而且,如果需要同一阵列“类型”的多份拷贝,也增加一栏。

在计划实现正常化之前增加表数(很少或根本没有重复/复制)。 不要增加表数,而要谨慎地增加新的业绩表(除少数例外情况外,现代数据库比你想象的更快),或处理边缘案例,如申请一生出现重复,或加之1%。

It also would be easier to understand your question if we knew the domain of the question-- are these addresses, customers, books, or what?





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签