ruby on rails - Schemaless DBs: Indexing dynamically-typed things by their properties? -


in rdbms can declare types (tables) , subtypes (subtype tables supertype fks). in rails class table inheritance. example, have person table , friend subtype table more personal details person (e.g. birthday/anniversary).

when leap nosql world , use document db mongodb implementing subtypes easier since collections schema-less. ideal creating cms. can dynamically type anything. in fact, thing can multi-typed having properties of types. not tricky either.

but here's tricky part. want index dynamically typed things (e.g. "things" collection). want search event things start_date. want search people things name. want search friend things birthdate. when you're not dynamically typing things each of these types have own collection. indexing events, people, friends dynamically-typed things tough. indexing events, people, friends types (tables or collections) not tough.

it seems me mongodb (and other schema-less databases) made dynamic typing. @ least, in respects. when comes indexing dynamically-typed things, falls short. how have/would tackle problem?

i think if mongodb introduces filtered indexes we'll there. (filtered indexes solve problem in way multikeys , sparse indexes cannot.) other thing need potentially unlimited number of indexes (since have users creating lots of custom types). without uncapped number of indexes pose limitation on number of types such database handle.

please vote in support if agree filtered indexes solve dynamic-typing issue.

this question simplifies , clarifies a question asked earlier. comes @ problem different angle.

speaking mongodb pov, there no reason why couldn't set separate index each subtype. mongomapper, (i don't know mongoid), add _type key collection represents each subtype. can use _type key in index in order filter of sorts.

db.people.ensureindex({_type:1,birthdate:1}) 

and on.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -