Tuesday 15 January 2013

nosql - representing a many-to-many relationship in couchDB -


Assume that I am writing a log analysis application, the main domain object will be a LogEntry along with it. Users of the application define a logotype that indicates which listings they are interested in. As the app receives log entries, they think they are connected to DB, and all the people in the system check them against the system so that they can match the criteria in this regard. . If this happens then the system should record that the entry matches the subject. Thus, there are many-to-many relationships between LogEntries and LogTopics.

If I was storing it in RDBMS, I would do something like this:

  create table entry (Id int, ...) Create table topic (id int, ..) Create table subject antrimap (EntryId, Subject_ID ANI)  

Using CHDB I have only two documents before I tried a type of LogEntry type, looking something like this:

  {'type': 'LogEntry', 'severity': 'DE BUG ', ...}   

And I have a logotype type, which looks like this:

  {' type ':' Logotyic ',' Mailing_entry ': [' log_entry_1 ',' log_entry_12 ',' Log_entry_34 ', ....], ...}  

You can see that I am using all logostic documents It represents a relationship by using a matching_entries field in order to store a list of log entry document IDs works fine until one point, but I have problems When you try to add a matching entry in both more than one client a topic efforts both optimistic updates, and one fails. The solution I am using now is essentially to regenerate the RDBMS approach, and adds a third document type, such as something:

  {'type': 'LogTopicToLogEntryMap', 'topic_id': 'topic_12 this works, and concurrent updates occur before problems, but I have two reservations: 

  1. I worry that I just have this approach I am using because it is what I will do in a relational DBI wonder if another couch is a DB-like (relaxed?) Solution
  2. My thoughts can not retrieve all entries for a specific topic in a call. My last solution is allowed (if I used the include_docs parameter).

Anyone have a better solution for me? If I can also post thoughts I'm using?

Your approach is okay, using Cochchadi does not mean that you will only leave relational modeling . You will need to run two questions, but this is because because it is "included", the SQL questions are also slow with connecting but SQL syntax allows you to express the query in a statement.

In my few months of experience with CouchDB, I have found this:

  1. There is no schema, so designing the app model is fast and flexible
  2. There is a CRUD, so increasing your application is fast and flexible.
  3. Bye SQL injection
  4. What will happen in a SQL insertion takes a little more work in Wikipedia:

According to your needs I have found that Couched-Lucene is also more complicated Useful for the construction of houses.


No comments:

Post a Comment