简体   繁体   English

mysql数据库存储最佳实践,用于存储数据(少量或少量大量)

[英]mysql database storing best practice for storing data, lots of small amounts or small amounts of large

I have two tables that hold information, one of properties and one of investors and I want to store investors that are interested in certain properties. 我有两个保存信息的表,一个是房地产,另一个是投资者,我想存储对某些房地产感兴趣的投资者。

I am making a third linking table to store this information, but I'm not sure which is best practice, should I store one investor ID and many property ID's in one row (or one property ID to investor ID's) or should I do individual ones? 我正在制作第三个链接表来存储此信息,但是我不确定哪种方法是最佳做法,我应该将一个投资者ID和许多财产ID存储在一行中(或者将一个财产ID存储到投资者ID中)还是应该单独存储?那些?

My problem is if I do individual ones the number of rows could easily go into the tens of thousands in a couple of months, but having many in one column will be a hefty number too. 我的问题是,如果我做单个行,那么几个月内行的数量很容易达到几万行,但是在一列中有很多行也将是一个庞大的数字。

Which is best practice? 哪个是最佳做法? Small quantity of large data, or large quantities of small data? 少量的大数据还是大量的小数据?

(Also worth mentioning that I need to keep the data for reports so deleting them is out of the question.) (还值得一提的是,我需要保留报告数据,因此将其删除是不可能的。)

The "Best Practice" is going to be to normalize your data, which in this case sounds like having large quantities of small data. “最佳实践”将使您的数据规范化 ,在这种情况下,这听起来像是拥有大量小数据。 Assuming you make both records the primary key, this look up should be relatively fast even for tens of thousands of rows. 假设您将两个记录都设为主键,那么即使对于成千上万的行,此查找也应该相对较快。

Also in general you wont' have issues with data in SQL until you hit millions and for small properly indexed tables like this I don't forsee an issue. 同样,一般来说,SQL中的数据不会有问题,直到您达到数百万,并且对于像这样的正确索引的小型表,我不会遇到任何问题。

Normalizing your data says that your linking table should store just one investor ID and one property ID. 对数据进行规范化表示,链接表应仅存储一个投资者ID和一个财产ID。

Have tens of thousands of records isn't generally considered to be a large number for a MySQL table to hold. 对于MySQL表而言,拥有成千上万的记录通常不被认为是一个大数目。 Just make sure you're indexing things properly to help speed up access. 只要确保您正确地索引事物,以帮助加快访问速度即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM