向我的网站上的每个用户分配MySQL数据库是不合理的吗? [英] Is it unreasonable to assign a MySQL database to each user on my site?

查看:115
本文介绍了向我的网站上的每个用户分配MySQL数据库是不合理的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个基于用户的网站。对于每个用户,我需要一些MySQL表来存储不同类型的信息(即userInfo,quotesSubmitted和ratesSubmitted)。它是一个更好的主意:



a)为网站(即mySite)创建一个数据库,然后在这里面有数百或数千个表,userInfo_bob,quotessubmitted_bob,userInfo_shelly和quotesSubmitted_shelly)





b )创建数百或数千个数据库(即Bob,Shelly等),每个数据库只有几个表(即Bob内部:userInfo,quotesSubmitted,ratesSubmitted等) p>

我应该使用一个数据库,该数据库中有多个表,还是多个数据库和每个数据库只有几个表?






编辑:



问题是,我需要跟踪谁给谁评分。这意味着如果用户评分为300的报价,我需要能够确切地知道用户评价了哪些报价。



也许我应该这样做?



一个表格用于引号。一个表来列出用户。一个表格,用于记录已完成的所有评分(即三列:用户,报价,评级)。这似乎是合理的。是否有任何问题?

解决方案

使用一个数据库。



使用一个表来保存用户和一个表来保存引号。



在这两个表之间,您有一个表,其中包含与用户匹配引用的信息,此表将保持用户给出报价的评级。



这个简单的设计将允许您存储几乎无限数量的报价,无限用户,您将能够



中间的表格将包含外键到用户和引号表。



您可能会发现查看一些数据库设计基础很有帮助,stackoverflow上有很多相关问题。



开始使用这些...



什么是规范化?





多少字段数量过多?



更多表格或更多列?


I'm creating a user-based website. For each user, I'll need a few MySQL tables to store different types of information (that is, userInfo, quotesSubmitted, and ratesSubmitted). Is it a better idea to:

a) Create one database for the site (that is, "mySite") and then hundreds or thousands of tables inside this (that is, "userInfo_bob", "quotessubmitted_bob", "userInfo_shelly", and"quotesSubmitted_shelly")

or

b) Create hundreds or thousands of databases (that is, "Bob", "Shelly", etc.) and only a couple tables per database (that is, Inside of "Bob": userInfo, quotesSubmitted, ratesSubmitted, etc.)

Should I use one database, and many tables in that database, or many databases and few tables per database?


Edit:

The problem is that I need to keep track of who has rated what. That means if a user has rated 300 quotes, I need to be able to know exactly which quotes the user has rated.

Maybe I should do this?

One table for quotes. One table to list users. One table to document ALL ratings that have been made (that is, Three columns: User, Quote, rating). That seems reasonable. Is there any problem with that?

解决方案

Use one database.

Use one table to hold users and one table to hold quotes.

In between those two tables you have a table that contains information to match users to quotes, this table will hold the rating that a user has given a quote.

This simple design will allow you to store a practically unlimited number of quotes, unlimited users, and you will be able to match up each quote to zero or more users and vice versa.

The table in the middle will contain foreign keys to the user and quote tables.

You might find it helpful to review some database design basics, there are plenty of related questions here on stackoverflow.

Start with these...

What is normalisation?

What is important to keep in mind when designing a database

How many fields is 'too many'?

More tables or more columns?

这篇关于向我的网站上的每个用户分配MySQL数据库是不合理的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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