0

I've got years of experience with SQL. I'm starting on a side project with a fairly simple (to me) data model. I've read a number of posts, articles, guides, etc. over the last few weeks and am trying to wrap my head around SQL vs NoSQL, particularly the relationship component.

As a hypothetical, say my application is something that you'll store some search terms you're interested in and there will be a job that runs nightly to query some data source for those search terms. Hits on those terms will be compared to what's been seen before and you'll get notified that there are new results. From those results, you'll flag ones you're interested in following for further activity (another nightly job to search for those)

For more concrete examples (but none that I'm planning, the source of data I'm querying is comparatively finite), you're interested in finding books (source is Amazon, Goodreads, etc.) or movies (IMDB, Rotten Tomatoes) for things you're interested in (search terms: "medieval history", "commercial fishing", "alien abduction") and when you get results back, you flag some books/movies that you're interested in and want to get notified (activity: book is released in paperback format; movie is opening in theaters)

The way I envision storing the data, there's a relationship between the hits/results and the term(s) that produced those hits.

In a RDBMS, I'd have a simple structure like this enter image description here

With this structure, I can ask for and get a list of search terms associated with a particular result or a list of results for a specific search term pretty easily. I could also get a list of all paperback releases (activity) in the next week.

Thinking that document-based would be the NoSQL approach to use if going that route, a similarly simple structure I can imagine for a Result as a document would be:

{
   "id" : 1,
   "url" : "https://something.com/idxyz123",
   "summary" : "Great book about alien abduction aboard a commercial fishing vessel",
   "follow" : true,
   "matchedSearchTerms" : [ "commercial fishing", "alien abduction" ]
   "activity" : [
      {
         "description" : "Paperback Release",
         "eventDate" : "2022-10-15"
      },
      {
         "description" : "eBook Release",
         "eventDate" : "2023-02-01"
      }
    ]
}

Where I'm struggling is whether the relationship between search terms and results is a relationship that "violates" NoSQL principles, and if not, if there's an approach where there's a document for SearchTerm with an id and the matches would be reprsented in the Result document like "matchedSearchTermIds" : [1, 3]

As far as ACID goes, there'd be a very limited number of users (small family) and little concurrent activity outside the control of the nightly jobs so it's not a concern for a NoSQL approach.

So even though this is a side project, just understanding the approach one would take (both SQL vs NoSQL and the NoSQL approach if it makes sense) would help me immensely!

5
  • 1
    NoSQL doesn't do the same kind of relationships. Instead of separate entities, you have documents where the entire value of an item is included with each document, included any related data. This means you don't do normalization which, yes, means some data is duplicated and updating "shared" records can be challenging. The tradeoff is retrieving an object graph is much simpler, since the whole graph is there with that one document. Commented Sep 30, 2022 at 14:39
  • I agree with @JoelCoehoorn. I would add that relational and non-relational databases can complement each other, since they can resolve different problems. For the transactional part of your app you can use a relational db, while high-demand quick page views can be served by nosql databases. A process can sync those two databases appropriately. Commented Sep 30, 2022 at 14:52
  • 1
    You are experiencing one of the extra costs of NoSQL, extra developer, debugging and support costs/time.
    – snj
    Commented Sep 30, 2022 at 15:28
  • Note that when you say NoSQL, you mean a document-oriented database. Meanwhile there are other types of NoSQL: key-value, columnar, graph. Commented Sep 30, 2022 at 20:54
  • @AlexanderPetrov I'm aware of the other types but from what I understood of the options, document seemed like the most appropriate fit. Do you feel that's not the case here?
    – CaseyR
    Commented Oct 1, 2022 at 21:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.