Say I'm writing a log analysis application. The primary domain object will be LogEntry. Also. application users define LogTopic, which describes which log entries they are interested in. Since the application receives journal entries, it adds them to couchDB, and also checks them on all LogTopics in the system to see if they meet the criteria in the topic. If this happens, the system should record that the record matches the topic. Thus, there is a many-to-many relationship between LogEntries and LogTopics.
If I stored this in a DBMS, I would do something like:
CREATE TABLE Entry (
id int,
...
)
CREATE TABLE Topic (
id int,
...
)
CREATE TABLE TopicEntryMap (
entry_id int,
topic_id int
)
Using CouchDB, at first I tried to have only two types of document. I will have a LogEntry type that looks something like this:
{
'type': 'LogEntry',
'severity': 'DEBUG',
...
}
LogTopic, :
{
'type': 'LogTopic',
'matching_entries': ['log_entry_1','log_entry_12','log_entry_34',....],
...
}
, , matching_entries LogTopic LogEntry. , , . , . , , , RDBMS , :
{
'type':'LogTopicToLogEntryMap',
'topic_id':'topic_12',
'entry_id':'entry_15'
}
, :
- ,
,
. ,
couchDB- (?)
.
- .
(
include_docs).
- ? , , ?