I want to store "Tweets" and "Facebook Status" in my app as part of "Status collection" so every status collection will have a bunch of Tweets or a bunch of Facebook Statuses. For Facebook I'm only interested in text so I won't store videos/photos for now.
我想将“Tweets”和“Facebook状态”作为“Status collection”的一部分,存储在我的app中,这样每个Status collection都会有一堆Tweets或者一堆Facebook状态。对于Facebook,我只对文本感兴趣,所以我暂时不会存储视频/照片。
I was wondering in terms of best practice for DB design. Is it better to have one table (put the max for status to 420 to include both Facebook and Twitter limit) with "Type" column that determines what status it is or is it better to have two separate tables? and Why?
我想知道DB设计的最佳实践。使用“Type”列(确定状态是什么)是更好的(将状态的最大值设为420,以同时包含Facebook和Twitter的限制),还是使用两个单独的表更好?,为什么?
3 个解决方案
#1
1
Strictly speaking, a tweet is not the same thing as a FB update. You may be ignoring non-text for now, but you may change your mind later and be stuck with a model that doesn't work. As a general rule, objects should not be treated as interchangeable unless they really are. If they are merely similar, you should either use 2 separate tables or use additional columns as necessary.
严格地说,tweet与FB更新不一样。您可能暂时忽略了非文本,但稍后您可能会改变您的想法,从而陷入无法工作的模型中。一般来说,对象不应该被视为可互换的,除非它们确实是可互换的。如果它们仅仅是相似的,您应该使用两个单独的表,或者根据需要使用其他列。
All that said, if it's really just text, you can probably get away with a single table. But this is a matter of opinion and you'll probably get lots of answers.
也就是说,如果只是文本,你可能只需要一个表就行了。但这是一个观点问题,你可能会得到很多答案。
#2
1
I would put the messages into one table and have another that defines the type:
我会把消息放在一个表中,另一个表定义类型:
SocialMediaMessage
------------------
id
SocialMediaTypeId
Message
SocialMediaType
---------------
Id
Name
They seem similar enough that there is no point to separate them. It will also make your life easier if you want to query across both Social Networking sites.
他们看起来很相似,没有必要把他们分开。如果你想在两个社交网站上进行查询,这也会让你的生活更轻松。
#3
1
Its probably easier to use on table and use type to identify them. You will only need one query/stored procedure to access the data instead of one query for each type when you have multiple tables.
它可能更容易使用在表和使用类型来识别它们。当您有多个表时,您将只需要一个查询/存储过程来访问数据,而不是每个类型的一个查询。
#1
1
Strictly speaking, a tweet is not the same thing as a FB update. You may be ignoring non-text for now, but you may change your mind later and be stuck with a model that doesn't work. As a general rule, objects should not be treated as interchangeable unless they really are. If they are merely similar, you should either use 2 separate tables or use additional columns as necessary.
严格地说,tweet与FB更新不一样。您可能暂时忽略了非文本,但稍后您可能会改变您的想法,从而陷入无法工作的模型中。一般来说,对象不应该被视为可互换的,除非它们确实是可互换的。如果它们仅仅是相似的,您应该使用两个单独的表,或者根据需要使用其他列。
All that said, if it's really just text, you can probably get away with a single table. But this is a matter of opinion and you'll probably get lots of answers.
也就是说,如果只是文本,你可能只需要一个表就行了。但这是一个观点问题,你可能会得到很多答案。
#2
1
I would put the messages into one table and have another that defines the type:
我会把消息放在一个表中,另一个表定义类型:
SocialMediaMessage
------------------
id
SocialMediaTypeId
Message
SocialMediaType
---------------
Id
Name
They seem similar enough that there is no point to separate them. It will also make your life easier if you want to query across both Social Networking sites.
他们看起来很相似,没有必要把他们分开。如果你想在两个社交网站上进行查询,这也会让你的生活更轻松。
#3
1
Its probably easier to use on table and use type to identify them. You will only need one query/stored procedure to access the data instead of one query for each type when you have multiple tables.
它可能更容易使用在表和使用类型来识别它们。当您有多个表时,您将只需要一个查询/存储过程来访问数据,而不是每个类型的一个查询。