热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

我可以在社交网站中为每个用户创建每个表吗?-Canicreateeachtableforeachuserinmysocialnetworkingsite?

ImcreatingasocialnetworkingsitewithfeaturessimilartoFacebook.Iwanttostartwithschema

I'm creating a social networking site with features similar to Facebook. I want to start with schema design for my database. What i thought was to create each table for each user who registers to our site.. am i doing right?

我正在创建一个功能类似于Facebook的社交网站。我想从我的数据库的架构设计开始。我想的是为每个注册到我们网站的用户创建每个表..我做得对吗?

If a million users register to my site, a million tables will be created. how to go on about optimizing this? Please do suggest me techniques to overcome this and some references or books to learn about such concepts will be vry useful..

如果有一百万用户注册到我的网站,将创建一百万个表。如何继续优化这个?请建议我克服这个的技巧,一些参考或书籍,以了解这些概念将是有用的..

Thanks in Advance.

提前致谢。

2 个解决方案

#1


6  

This is not the way you want to do it.

这不是你想要的方式。

What you want to do is have a table (perhaps called 'users') that contains one row for each user that registers. Creating a new table for each user is completely pointless and would cause terrible performance.

你想要做的是有一个表(可能称为'用户'),每个用户注册一行。为每个用户创建一个新表是完全没有意义的,会导致糟糕的性能。

Maybe something like this:

也许是这样的:

 TABLE users
   - username AS VARCHAR(255)
   - password AS VARCHAR(255) (use a hashed password, of course)
   - ...

Then when a user registers, simply insert the information they provide into the users table as a new row.

然后,当用户注册时,只需将他们提供的信息作为新行插入到users表中。

#2


2  

That would be massive overkill. You should probably read up on database design (start with normalisation, but don't overdo it). Then write down what you want to save for each user, and think about how to save it without saving data double.

这将是巨大的矫枉过正。您应该阅读数据库设计(从规范化开始,但不要过度)。然后记下您要为每个用户保存的内容,并考虑如何在不保存数据的情况下保存它。

But I'm pretty sure a table-per-user is not an option for this.

但我很确定每个用户的表不是一个选项。


推荐阅读
author-avatar
mobiledu2502881767
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有