is this sort of SQL structuring (in a mysql database) efficient in a real world model?

℡╲_俬逩灬. 提交于 2020-01-05 07:05:01

问题


i was hoping to get feedback on an example mysql structure for a web application in a real world environment from people who have used complex mysql in real world situations before.

example ~

education management app. 80,000 users. each user gets his own database containing tables for -messages -uploads -grades -info

and more tables for other features

what I'm wondering is, and any info would be appreciated, in a situation like this

-is this databasing model efficient? (basically like 80,000 databases) or is there (and I have this itching feeling there is) a better way to do it? -what kind of dedicated server would this require? 80,000 databases each with 10-15 tables containing TONS of tables, with all 80,000 people accessing the site 20-30 times a day for 10-20 sessions


回答1:


Start running.

Now!

Jokes aside, don't do that. Don't create one database per user. That's a hell to administer, maintain and to query. What if you need to know which users logged in yesterday? Will you query each database??

The structure you need is the same, only the amount of data changes. Just have one database, see how it goes and then optimize/fine tune.

I hate to bring this quote up, but in your case it totally applies:

Premature optimization is the root of all evil (Donald Knuth)

Don't try to optimize your solution before you know where your bottlenecks will be.

Just model your database the best you can. Worry about your constraints, PKs, FKs, Indexes. Do your database-design homework. Then have your data and software going. Only then you will see where it works and where it hurts. At this moment, you optimize.

Only attack your enemy when you know who it is.




回答2:


it can be efficient with the appropiate store engine to support that model. Most of the recent no-sql data stores (hadoop, bigtable, mongodb, etc.) work great for this sort of scenario.

If you think about it, a user data is an excellent way to partition data stores in isolated islands (most of interactions between different user databases does not need to be transactional, and there is very little if any exchange of write requests)

Basically i would think that no-sql doesn't give you any benefits for data relationships inside the user data island itself, so relational and no-relational stores performance differences should not matter that much

Given said that, traditional relational databases as mysql are not designed to be managed in-masse, so in this respect you might want to consider a different data store (or hiring a dba rock star)




回答3:


Both Adrian and Lurscher have already given lot of details.

Without knowing how much data and the schema it is hard to get into design. From outset with 80K active users the load doesn't seem to be huge even if they access the data hundreds of times a day. I have a feeling you could be able to create normalized schema for an OLTP environment with users table and work from there with other tables. And again it is the requirement that will drive the design. For example, what should be the response time for user query - sub-second, a second?



来源:https://stackoverflow.com/questions/9612173/is-this-sort-of-sql-structuring-in-a-mysql-database-efficient-in-a-real-world

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!