nosql - Matching items with multiple foreign keys in RavenDB -



nosql - Matching items with multiple foreign keys in RavenDB -

i asked question regarding sql server: complicated sql query--finding items matching multiple diferent foreign keys

basically, need able find products match multiple criteria. have scenario need find products match each of multiple categories , found in multiple invoices.

the solution rather complex set of unions, amounts counting number times product matched criteria , filtering items count matched count of criteria.

; info (id, count) ( select pc.productid, count(*) productcategories pc (nolock) inner bring together @categoryids /*table valued param*/ c on c.id = pc.categoryid union select ip.productid, count(*) invoiceproducts ip (nolock) inner bring together @invoiceids on i.id = ip.invoiceid ) select d.id info d grouping d.id having sum(d.count) = @matchcount

but now, considering nosql provider. question is, how create index function match kind of query in ravendb (or other nosql project)?

a mental shift required set ravendb (or other document db). problem hacks used create when working structured info against sql server.

therefore, question here how info modeled. more exact - how going utilize often; based on there guidelines on entities define , how link them together.

for simple product object, string[] of categories, can query db this:

// query on nested collections - homecoming product category "c#" products = p in session.query<product>() p.categories.any(cat => cat == "c#") select c;

you can add together many clauses want. index automatically created - recommended utilize static indexes when you've settled on model.

more on topic:

http://ayende.com/blog/4801/leaving-the-relational-mindset-ravendbs-trees

https://github.com/ravendb/docs

nosql ravendb

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -