data-modeling

Firestore: How to get random documents in a collection

我的未来我决定 提交于 2019-11-26 00:33:45
问题 It is crucial for my application to be able to select multiple documents at random from a collection in firebase. Since there is no native function built in to Firebase (that I know of) to achieve a query that does just this, my first thought was to use query cursors to select a random start and end index provided that I have the number of documents in the collection. This approach would work but only in a limited fashion since every document would be served up in sequence with its

What's the difference between identifying and non-identifying relationships?

谁都会走 提交于 2019-11-25 23:35:49
问题 I haven\'t been able to fully grasp the differences. Can you describe both concepts and use real world examples? 回答1: An identifying relationship is when the existence of a row in a child table depends on a row in a parent table. This may be confusing because it's common practice these days to create a pseudokey for a child table, but not make the foreign key to the parent part of the child's primary key. Formally, the "right" way to do this is to make the foreign key part of the child's

Recommended SQL database design for tags or tagging [closed]

我的未来我决定 提交于 2019-11-25 21:59:22
问题 I\'ve heard of a few ways to implement tagging; using a mapping table between TagID and ItemID (makes sense to me, but does it scale?), adding a fixed number of possible TagID columns to ItemID (seems like a bad idea), Keeping tags in a text column that\'s comma separated (sounds crazy but could work). I\'ve even heard someone recommend a sparse matrix, but then how do the tag names grow gracefully? Am I missing a best practice for tags? 回答1: Three tables (one for storing all items, one for

How to do Inheritance Modeling in Relational Databases?

强颜欢笑 提交于 2019-11-25 19:25:21
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. Martin Fowler discusses this extensively in his book Patterns of Enterprise Application Architecture book. Get this book and look into: Single Table Inheritance Class Table Inheritance Concrete Table Inheritance The Website should give you