关于MySQL关系数据库设计的快速提示

时间:2020-12-27 12:50:55

I have a webapp I'm making that stores user information, and their preferences regarding the app. Is this something worth splitting into two databases? I was thinking one table "users" with fields "id, useridfromFacebook, facebookRealName" (so 1, 52052025295, Alex McP), and then have a table "preferences" with fields "id, useridfromFacebook, emails, colors, SomeQuoteorSomething" (4, 52052025295, 1, 441155, 'Only The Good Die Young')

我有一个webapp我正在制作存储用户信息,以及他们对应用程序的偏好。这个值得分成两个数据库吗?我在想一个表“用户”,其字段为“id,useridfromFacebook,facebookRealName”(所以1,52052025295,Alex McP),然后有一个表“首选项”,字段为“id,useridfromFacebook,email,colors,SomeQuoteorSomething”(4 ,52052025295,1,441155,'只有好死的年轻')

I've never been taught/learned myself about DB setup, but this seems like it would limit the load on the database because when a user is authenticated and has installed the app, I would only need to query the preferences table if(isset($fbauthboolean)) or something.

我从未接受过有关数据库设置的教育/学习,但这似乎会限制数据库的负载,因为当用户通过身份验证并安装了应用程序时,我只需要查询首选项表if(isset( $ fbauthboolean))或其他东西。

Thoughts? Can I clarify this?

思考?我可以澄清一下吗?

Thanks!

I confused the words "database" and "table" in my original posting. Edited. I'd have just ONE DB with multiple tables, but all relating to the same user. One table contains NAME data, and the other table would store PREFERENCES type data

我在原始帖子中混淆了“数据库”和“表格”这两个词。编辑。我只有一个包含多个表的数据库,但都与同一个用户有关。一个表包含NAME数据,另一个表存储PREFERENCES类型数据

2 个解决方案

#1


I wouldn't think you'd need two databases, but you might want separate tables in the same schema.

我不认为您需要两个数据库,但您可能需要在同一模式中使用单独的表。

I really liked Toby Teorey's "Database Modeling and Design". See if you agree.

我非常喜欢Toby Teorey的“数据库建模和设计”。看看你是否同意。

I also like the Database Programmer blog. Very helpful, good writing.

我也喜欢Database Programmer博客。非常有帮助,写得很好。

If you don't want to buy a book, you might want to Google for normalization.

如果您不想购买图书,可能需要Google进行规范化。

#2


For your preferences table, I'd go something like

对于你的偏好表,我会像

Preferences( pref_id, facebook_id, preference, value)

Where preference was some code like 'Quote','AboutMe', etc, and value being a string.

偏好是一些代码,如'Quote','AboutMe'等,值是一个字符串。

You could even have a preference_value table with a list of 'QUOTE','Funny Quote'/'ABOUTME, 'About Me', etc

你甚至可以有一个preference_value表,其中包含'QUOTE','Funny Quote'/'ABOUTME,'About Me'等列表

#1


I wouldn't think you'd need two databases, but you might want separate tables in the same schema.

我不认为您需要两个数据库,但您可能需要在同一模式中使用单独的表。

I really liked Toby Teorey's "Database Modeling and Design". See if you agree.

我非常喜欢Toby Teorey的“数据库建模和设计”。看看你是否同意。

I also like the Database Programmer blog. Very helpful, good writing.

我也喜欢Database Programmer博客。非常有帮助,写得很好。

If you don't want to buy a book, you might want to Google for normalization.

如果您不想购买图书,可能需要Google进行规范化。

#2


For your preferences table, I'd go something like

对于你的偏好表,我会像

Preferences( pref_id, facebook_id, preference, value)

Where preference was some code like 'Quote','AboutMe', etc, and value being a string.

偏好是一些代码,如'Quote','AboutMe'等,值是一个字符串。

You could even have a preference_value table with a list of 'QUOTE','Funny Quote'/'ABOUTME, 'About Me', etc

你甚至可以有一个preference_value表,其中包含'QUOTE','Funny Quote'/'ABOUTME,'About Me'等列表