Domanda

I want to deploy a small web project I have in mind, where the data I want to save are structs with nested structs inside, and most of the times the inner structs does not have the same fields and types.

for example, I'd like something like that, to be a "row" in a table

{ 
  event : "The Oscars",
  place : "Los Angeles, USA",
  date : "March 2, 2014"
  awards :
  [

    bestMovie : 
    [

      name : "someName",
      director : "someDirector",
      actors :
      [
        ... etc
      ]

    ],

    bestActor : "someActor"

  ]

}

( JSON objects are easy to use for me at the moment, and passing it between server and client side. The client-side is run on JavaScript )

I started with MySQL/PHP but very soon I saw that it doesn't suit me. I tried mongoDB for a few days but I don't know how exactly to refine my search on which is the best db to use. I want to be able to set some object models/schemas, and select exactly which part to update and which fields are unique in each struct.

Any suggestions? Thanks.

È stato utile?

Soluzione

This is not an answerable question so will likely be closed. There is no one right answer here and there are a few questions to ask such as data structure, speed requirements, and the old CAP Theorem questions of what do you need:

  • Consistency
  • Availability
  • Partition-ability

I would suggest mongo will be a great place to start if you are casually working away and don't anticipate having to deal with any of the issues above at scale. Couch is another similar option but doesn't have the same community size.

I say mongo because your data is denormalized into a document and mongo is good at serving documents. It also speaks json!

RDBMS databases would require you to denormalize your documents and create relationships which is quite a bit of work from where you are relative to sticking the documents into a document.

You could serialize the data using protocol buffers and put that in an rdbms but this is not advisable.

For blazing speed you could use redis which has constant time lookups in memory. But this is better suited (in most cases) for ephemeral data like user sessions - not long term persistant storage.

Finally there are graph databases like neo4j which are document-like databases which store relationships between nodes with typed edges. This suits social and recommendation problems quite well but that's probably not the problem you're trying to solve - in the question it simply states what is best for your data for storage.

Looking at some of the possibilities, I think you'll probably find mongo best suits your needs as you already have json document structures and only need simple persistance for those documents.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top