0

I am creating a document for a client, where it requires for each particular customer to have multiple timestamp of entry whenever they visit. For example, everytime the customer visits the store, it stores the time and date, and the purpose of the visit. I am just curious in such behavior, if its an existing customer, does it make sense to add multiple entries of the same data, or how would that work in nosql logic? I am a bit confused if I want the same redundant data on the same document how should I achieve it? Or maybe an array would be a good choice?

Thanks.

topgun
  • 2,463
  • 8
  • 31
  • 46
  • What do you want to do with the data eventually? That's one of the most important questions to answer. Is it a log? Could your "log" just store IDs of customers (thereby reducing duplication)? Then, create a view to collate customers by dates by log entry. – WiredPrairie Feb 04 '13 at 16:56
  • All I want is to add certain dates, times and type of service. It would be just used for reporting purpose. I can view a particular customer's visit to the current store through out since s/he have come to the store. Plus its not a duplicate date rather a +1 incremental of the visit. – topgun Feb 04 '13 at 17:36
  • 1
    I'd just store them as new docs with a customer id, timestamp, etc. Then, create a view to collate them as needed. – WiredPrairie Feb 04 '13 at 18:23
  • or can't you have a set of "Entries" arrays of dictionary within the document and have collection of entries data in each set of array.. But obviously your approach is simplerer, however, thats more of a duplication approach. That's what I am trying to understand, on day to day basis, the growth of documents will just because exponential rapidly, but then I can clean that at the server end using views. – topgun Feb 04 '13 at 18:46
  • You could I suppose, but unless you always need all the data every time you access the document, I wouldn't; this wouldn't be a typical way to model a structure in CouchDB. – WiredPrairie Feb 04 '13 at 19:23
  • I see, thanks for your input WiredPrairie, I will certainly play with this and see how it goes. – topgun Feb 04 '13 at 20:22
  • If you have a limited number of items it is good to put it in the same document, in this case you focus on the retrieval of the data. As Wired Praired said it is probably not a good idea in your case. So it is better to use different document with a link between them. You can find good information about this in the Couchbase Developer Guide : http://www.couchbase.com/docs/couchbase-devguide-2.0/modeling-documents.html – Tug Grall Feb 07 '13 at 15:59

0 Answers0