data-modeling

Cassandra data modeling for one-to-many lookup

梦想与她 提交于 2020-01-01 19:11:11
问题 Consider the problem of storing users and their contacts. There are about a 100 million users, each has a few hundred contacts and on an average contacts are 1kb in size. There may be some users with too many contacts (>5000) and there may be some contacts that are much (say 10x) bigger than the average of 1kb. Users actively add contacts and less often also delete them. Contacts are not pointers to other users but just a bundle of information. There are two kinds of queries - Given a user

Cassandra data modeling for one-to-many lookup

冷暖自知 提交于 2020-01-01 19:10:07
问题 Consider the problem of storing users and their contacts. There are about a 100 million users, each has a few hundred contacts and on an average contacts are 1kb in size. There may be some users with too many contacts (>5000) and there may be some contacts that are much (say 10x) bigger than the average of 1kb. Users actively add contacts and less often also delete them. Contacts are not pointers to other users but just a bundle of information. There are two kinds of queries - Given a user

How would you model a friendship relationship in MongoDB?

不问归期 提交于 2020-01-01 03:48:20
问题 I know a lot of answers have been given that advise embedding an array of references to other users, but what all answers of this sort neglect is that friendship is a two-way relationship and that when Alice is Bob's friend, Bob is automatically Alice's friend. I'm not modeling followers. So I don't want to keep two references every time a new user enters the system. I need a model that takes into account the two-way nature of the relationship. I was thinking a collection of Friendship 'edges

How to properly cascade delete managed objects in Core Data?

一曲冷凌霜 提交于 2019-12-30 03:56:22
问题 I have a Core Data model which has three entities: A, B, and C. A has a one-to-many relationship with B, and B has a many-to-many relationship with C. The delete rule for A -> B is "Cascade", and B -> A is "No Action". The delete rule for B -> C is "No Action", and C -> B is "Deny". I am having trouble performing a delete on the A entity. What I want to happen is the following: I delete an instance of A (using deleteObject: ) The delete propagates to any B's associated with A (due to the

Data Modelling Advice for Blog Tagging system on Google App Engine

蓝咒 提交于 2019-12-29 13:33:50
问题 Am wondering if anyone might provide some conceptual advice on an efficient way to build a data model to accomplish the simple system described below. Am somewhat new to thinking in a non-relational manner and want to try avoiding any obvious pitfalls. It's my understanding that a basic principal is that "storage is cheap, don't worry about data duplication" as you might in a normalized RDBMS. What I'd like to model is: A blog article which can be given 0-n tags. Many blog articles can share

Data Modelling Advice for Blog Tagging system on Google App Engine

穿精又带淫゛_ 提交于 2019-12-29 13:31:34
问题 Am wondering if anyone might provide some conceptual advice on an efficient way to build a data model to accomplish the simple system described below. Am somewhat new to thinking in a non-relational manner and want to try avoiding any obvious pitfalls. It's my understanding that a basic principal is that "storage is cheap, don't worry about data duplication" as you might in a normalized RDBMS. What I'd like to model is: A blog article which can be given 0-n tags. Many blog articles can share

SQL - Should I use a junction table or not?

这一生的挚爱 提交于 2019-12-29 06:29:10
问题 I am creating a new SQL Server 2008 database. I have two two tables that are related. The first table looks like this: BRANDS // table name BrandID // pk BrandName // varchar The second table looks like this: MODELS // table name ModelID // pk ModelDescription // varchar Every brand will have at least one model and every model will belong to only one brand. The question is, should I create a junction table like this BRANDS_MODELS // table name RecordID // pk BrandID ModelID Or should I modify

What would be the purpose of putting all datastore entities in a single group?

狂风中的少年 提交于 2019-12-29 02:09:31
问题 I have started working on an existing project which uses Google Datastore where for some of the entity kinds every entity is assigned the same ancestor. Example: class BaseModel(ndb.Model): @classmethod def create(cls, **kwargs): return cls(parent=cls.make_key(), **kwargs) @classmethod def make_key(cls): return ndb.Key('Group', cls.key_name()) class Vehicle(BaseModel): @classmethod def key_name(cls): return 'vehicle_group' So the keys end up looking like this: Key(Group, 'vehicle_group',

What would be the purpose of putting all datastore entities in a single group?

前提是你 提交于 2019-12-29 02:09:08
问题 I have started working on an existing project which uses Google Datastore where for some of the entity kinds every entity is assigned the same ancestor. Example: class BaseModel(ndb.Model): @classmethod def create(cls, **kwargs): return cls(parent=cls.make_key(), **kwargs) @classmethod def make_key(cls): return ndb.Key('Group', cls.key_name()) class Vehicle(BaseModel): @classmethod def key_name(cls): return 'vehicle_group' So the keys end up looking like this: Key(Group, 'vehicle_group',

Cloud Firestore deep get with subcollection

匆匆过客 提交于 2019-12-28 03:32:07
问题 Let's say we have a root collection named 'todos'. Every document in this collection has: title : String subcollection named todo_items Every document in the subcollection todo_items has title : String completed : Boolean I know that querying in Cloud Firestore is shallow by default, which is great, but is there a way to query the todos and get results that include the subcollection todo_items automatically? In other words, how do I make the following query include the todo_items