data-modeling

Facebook like notifications tracking (DB Design)

寵の児 提交于 2019-11-26 08:47:27
问题 I am just trying to figure out how Facebook\'s database is structured for tracking notifications. I won\'t go much into complexity like Facebook is. If we imagine a simple table structure for notificaitons: notifications (id, userid, update, time); We can get the notifications of friends using: SELECT `userid`, `update`, `time` FROM `notifications` WHERE `userid` IN (... query for getting friends...) However, what should be the table structure to check out which notifications have been read

What's the best way to model recurring events in a calendar application?

坚强是说给别人听的谎言 提交于 2019-11-26 07:49:59
问题 I\'m building a group calendar application that needs to support recurring events, but all the solutions I\'ve come up with to handle these events seem like a hack. I can limit how far ahead one can look, and then generate all the events at once. Or I can store the events as repeating and dynamically display them when one looks ahead on the calendar, but I\'ll have to convert them to a normal event if someone wants to change the details on a particular instance of the event. I\'m sure there\

Relational database design question - Surrogate-key or Natural-key?

久未见 提交于 2019-11-26 07:48:22
问题 Which one is the best practice and Why ? a) Type Table, Surrogate/Artificial Key Foreign key is from user.type to type.id : b) Type Table, Natural Key Foreign key is from user.type to type.typeName : 回答1: I believe that in practice, using a natural key is rarely the best option. I would probably go for the surrogate key approach as in your first example. The following are the main disadvantages of the natural key approach: You might have an incorrect type name, or you may simply want to

What are the design criteria for primary keys?

Deadly 提交于 2019-11-26 06:07:38
问题 Choosing good primary keys, candidate keys and the foreign keys that use them is a vitally important database design task -- as much art as science. The design task has very specific design criteria. What are the criteria? 回答1: The criteria for consideration of a primary key are: Uniqueness Irreducibility (no subset of the key uniquely identifies a row in the table) Simplicity (so that relational representation & manipulation can be simpler) Stability (should not be altered frequently)

DB design to use sub-type or not?

混江龙づ霸主 提交于 2019-11-26 05:38:52
问题 The database I\'m designing has 3 major tables: BOOKS , ARTICLES , NOTES . Each book or article can have multiple notes, my original design was just like that, which means both notes on books and notes on articles go the \'notes\' table. Here are the columns for the NOTES table: note_id note_type note_type_id note_content NOTE_TYPE can be either \'book\' or \'article\'; NOTE_TYPE_ID is the FK for a book_id if the note_type is \'book\' OR an article id if the note_type is \'article\'. Now I

single fixed table with multiple columns vs flexible abstract tables

為{幸葍}努か 提交于 2019-11-26 03:47:25
问题 I was wondering if you have a website with a dozen different types of listings (Shops, Restaurants, Clubs, Hotels, Events) that require different fields, is there a benefit of creating a table with columns defined like so Example Shop: shop_id | name | X | Y | city | district | area | metro | station | address | phone | email | website | opening_hours Or a more abstract approach similar to this: object_id | name --------------- 1 | Messy Joe\'s 2 | Bate\'s Motel type_id | name ---------------

How to do Inheritance Modeling in Relational Databases?

一笑奈何 提交于 2019-11-26 03:21:26
问题 My question is regarding Inheritance modeling in Relational Database Systems. I have canonical data model and in that I have some fields related to pricing of product inheriting certain attributes from product table and I want to model this inheritance in MySQL relational database and so, \"How can we do Inheritance Modeling in Relational Databases ?\" Thanks. 回答1: Martin Fowler discusses this extensively in his book Patterns of Enterprise Application Architecture book. Get this book and look

What mysql database tables and relationships would support a Q&A survey with conditional questions? [closed]

Deadly 提交于 2019-11-26 03:02:22
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago . I\'m working on a fairly simple survey system right now. The database schema is going to be simple: a Survey table, in a one-to-many relation with Question table, which is in a one-to-many relation with the Answer table and with the PossibleAnswers table. Recently the customer

Are soft deletes a good idea? [duplicate]

耗尽温柔 提交于 2019-11-26 02:27:06
问题 This question already has an answer here: Physical vs. logical / soft delete of database record? 24 answers Are soft deletes a good idea or a bad idea? Instead of actually deleting a record in your database, you would just flag it as IsDeleted = true , and upon recovery of the record you could just flag it as False . Is this a good idea? Is it a better idea to physically delete the record, then move it to an archive database, and if the user wants the record back, then software will look for

How to Model a “likes” voting system with MongoDB

那年仲夏 提交于 2019-11-26 01:59:11
问题 Currently I am working on a mobile app. Basically people can post their photos and the followers can like the photos like Instagram. I use mongodb as the database. Like instagram, there might be a lot of likes for a single photos. So using a document for a single \"like\" with index seems not reasonable because it will waste a lot of memory. However, I\'d like a user add a like quickly. So my question is how to model the \"like\"? Basically the data model is much similar to instagram but