1

hopefully this is the right place to ask this kind of question.

I am working on a system that focuses on helping people give away things that they don't use anymore.

So, an object typically has the following attributes:

Object

  • registered by (user. doesn't change)
  • type (there could be from 3 to 5 types)
  • situation (changes every once in a while. mainly about the condition of the object)
  • localisation (current place where it is. changes frequently)
  • pictures (one or more)
  • list of users that possessed the object with the time interval in which the user had the object
  • list of comments about the object (contains user, date/timestamp, and text)

After thinking about all those requirements, I need to decide whether a relational or non-relational database is more appropriate for this case. My main concern is regarding the fields that need to be updated occasionally. As far as I'm concern, this would be one of the downsides if I decided to use NoSQL.

Also, I was hoping that I could use NodeJS for this project, although I've never seen anyone use Node with relational databases (I know it is possible, but is it recommended?)

If I end up using a relational database, is it correct to say that I would have at least 4 tables?

Object (FK for the user that registered the object)
User
Object_Users (maps Objects to Users)
Comment (FK for object and user)?

How could I do this using MongoDB, for instance?

After some thoughts, I came up with this, but I don't know if it is correct:

{
"object": {
    "type": "dvd",
    "situation": "Well preserved",
    "localization": "Birds Avenue",
    "user_name": "Larissa Leite",
    "user_img": "url",
    "events": [
        {
            "user_name": "Larissa Leite",
            "user_img": "url",
            "text": "Dvd registered",
            "date": "20/04/2014"
        }
    ],
    "comments": [
        {
            "user_name": "John Doe",
            "user_img": "url",
            "text": "Very good dvd",
            "date": "22/04/2014"
        }
    ]
  }
}

If anything is unclear, let me know! Thanks!

  • I found this post quite interesting, if it helps in your decision - ignoredbydinosaurs.com/2013/05/… – JoseTeixeira Aug 27 '14 at 10:48
  • Thank you! I will take a look. But, could you give say your thoughts towards my problem? – Larissa Leite Aug 27 '14 at 16:19
  • Mostly my experience is with relational DBs. Also I'd need to know the kind of info you want to get from it (like if you want reports, if with the list of users you want to track other time dependant stuff, etc). Given this I can't help you much choosing the best option (relational or not) for your scenario, yet I can lend some thoughts on the relational option. In this case you will also want a table for Pictures (FK for the related object), and the types might also justify a table (I didn't understood if an object can have 3-5 types or if it can have only 1 out of 3-5 existing types). – JoseTeixeira Aug 27 '14 at 18:28
  • My understanding of the difference is that the NO SQL databases gain improved performance by sacrificing transactional robustness. I would strongly recommend a RDBMS for any financial transactions you must support, but a NO SQL database for the presentation data might be appropriate if the query volume is considered to possibly overwhelm your available hardware. There is no reason why you cannot consider a hybrid solution when the two databases do not need to be strongly coupled. – Pieter Geerkens Aug 28 '14 at 2:11
  • Structure wise I would say that you don't require a "registered by" value. That can be inferred from the first user. The location could probably be against the user rather than the object and current location can be inferred from the last/current user. It also means if a user moves the object will move with them. – MickyT Aug 28 '14 at 2:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.