SQL中有多个表还是一个兆表? [英] Multiple tables or one mega-table in SQL?

查看:80
本文介绍了SQL中有多个表还是一个兆表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MySQL的新手.我正在尝试设计一个在线文件存储系统.实际的文件存储将单独处理-我只想使用MySQL创建文件元数据(例如,文件名,文件大小,文件类型,权限等)的数据库.我的系统最多需要处理1000个用户,每个用户最多可以存储1000个文件.

I am new to MySQL. I am trying to design an online file storage system. The actual file storage will be taken care of separately - I just want to use MySQL to make a database of file metadata (eg. file names, file sizes, file types, permissions, etc.). My system will need to handle up to 1000 users, who will each be able to store up to 1000 files.

我想创建一个文件记录数据库.最好是为每个用户创建一个文件记录表,然后创建另一个列出用户并引用相应表的表?还是我应该制作一个大文件记录表,然后仅添加一个名为用户"的列?

I want to create a database of file records. Is is best to create one file-record table per user, and then make another table which lists the users and references the corresponding tables? Or should I make one big table of file records, and then simply include a column called "user"?

我猜想多表方法的优点是我永远不必遍历1,000,000条记录.但是我对mySQL不太了解,所以我不知道是否有100万条记录需要处理.

I guess the advantage of the multiple table approach is that I never have to step through 1,000,000 records. But I don't know much about mySQL, so I don't know if 1,000,000 records is a lot to work through or not.

推荐答案

您应该制作一个大的文件记录表,并只需添加一个名为用户"的列即可.您不会创建单独的表来存储完全相同的信息.

You should make one big table of file records, and simply include a column called "user". You do NOT create separate tables that store the exact same information.

编辑:您应该创建一个大表,其中的一列存储着对用户的引用.已经建议用户名是一个适当的名称,但是您可以随意命名.实际的用户信息将需要放在单独的表中(通过此键链接).

You should create one big table with a column that stores a reference to the user. It has been suggested that userid would be an appropriate name, but you can call it whatever you like. The actual user information would need to be in a separate table (linked by this key).

这篇关于SQL中有多个表还是一个兆表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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