d2jsp
d2jsp Forums > Off-Topic > Programmer's Haven > Relational Vs Non-relational Databases
Add Reply New Topic New Poll
laztheripper
#1 Mar 4 2021 06:10am
Group: Member
Posts: 33,064
Joined: Mar 31 2010
Gold: 84,613.63
I'd like to discuss your thoughts on relational and non-relational databases (mainly) and their use cases. I'm more accustomed to fixed column schemas from relational dbs but I am considering switching to an alternative.
Here's an example schema where I'd want to consider speed and ease of access as keypoints:

Relational - One table for users, one table for the cars they own and one table with varying lengths of properties listed for each car. So the cars table would reference the user in the users table, and the properties would reference which car they belong to (all via unique id/key).

Non-Relational - Multiple ways of achieving this, but the most obvious to me would be an object for each user, which I can best describe or return in json, ie :
Code
{
"user":"bob",
"cars": [
{
"name": "lambo",
"props": {
"color": "val",
"something": "val",
"blah": "val"
}
},
{
some other car...
}
]
}


Let's also assume there's 10000 users and each user has 5000 cars, and each car has 100-1000 props (yes they're very rich :D)
As far as I've read, the latter should be easier to change at any point, be simple to access and also offer similar speed.
Thoughts ?

Klexmoo
#2 Mar 4 2021 05:03pm
Group: Member
Posts: 12,641
Joined: May 17 2013
Gold: 1,000.00
If you want to enforce any kind of relational constraints, you should use a relational database.

If you don't care about consistency, use a key-value store like CouchDB

If you only care about performance, use redis as a cache layer in front of whatever else you're using

Relational databases aren't slow, and at this point you can extend them with json blob columns in addition to your fixed schema for more flexibility anyway

This post was edited by Klexmoo on Mar 4 2021 05:05pm
Flitterwing
#3 Mar 6 2021 10:51pm
Group: Member
Posts: 16
Joined: Mar 5 2021
Gold: 2.67
i don't think you need to adopt one or the other.

at work, we use a relational database, but we do have json blob columns containing an object where it makes sense. for example, our document table has a json blob full of data captured from that document. if not, either the table would have a ton of columns or we would need more tables for no good reason.

those json blobs/objects can be transposed into columns and/or queried just as easily.
Go Back To Programmer's Haven Topic List
Add Reply New Topic New Poll