Which type of database should I pick? Relational vs NoSQL?

Maximilian

Lifer
Feb 8, 2004
12,604
15
81
I have no idea about databases...

What I want to do is store a username and password for each user for my web application. Also I want to store what they ate on a certain day and this will need to be updated each day but without overwriting any data, for example it should keep what the user ate yesterday so they can look back, I thought storing the food data in a List object and serializing it then stuffing it in a column might work. Don't know how else I would do that.

Im tinkering and researching how to use MySQL right now, the more I tinker and read the more it seems like a legacy PITA technology to use.

Should I use one of the newer NoSQL databases? This looks rather nice:
http://www.mkyong.com/mongodb/java-mongodb-hello-world-example/

I like how its all java code. So which is easier to use? Which will support storing an object better? MySQL and relational databases or MongoDB and its equivalents? For a complete beginner remember, this isnt an enterprise class application or anything!
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
postgresql and don't turn back. If you need to store schema-less data you can use their JSONB column, it's pretty awesome.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,560
4,473
75
Personally I've found Mongo slow and hard to work with. But the one time I used it involved Ruby on Rails, and that might have been part of the problem.

Also I want to store what they ate on a certain day and this will need to be updated each day but without overwriting any data, for example it should keep what the user ate yesterday so they can look back.... Don't know how else I would do that.

Alright, here's how I'd do that in a traditional SQL database:

Table 1: users. Each user has an integer UID. What else you put in there is your business. ;)

Table 2: foods. Each food has an integer FID (Food ID).

Table 3: foodlog. These three columns are essential: UID, FID, and a date/timestamp. You probably also want a FLID (Food Log ID) index. I guess you might add a quantity column too.
 

owensdj

Golden Member
Jul 14, 2000
1,711
6
81
For what you're doing you can't go wrong with a relational database like MySQL.
 

clamum

Lifer
Feb 13, 2003
26,252
403
126
Another vote for SQL database (admittedly I've never used NoSQL), and Ken g6's suggestion is how I'd do it.

I'm partial to Microsoft SQL but you may not have access to it. Don't they have a free version though?
 

Graze

Senior member
Nov 27, 2012
468
1
0
Im tinkering and researching how to use MySQL right now, the more I tinker and read the more it seems like a legacy PITA technology to use.

What are you even talking about here?

I have no idea about databases...

Oh this might explain what you are talking about :confused:


Any half decent relational database under the sun would work for you. MYSQL is fine Postgre would be better
 

purbeast0

No Lifer
Sep 13, 2001
53,452
6,299
126
i've used sql and mongo for professional webapps, and i'd pick mongo over sql any day of the week as long as the db does not need to be scalable and won't be a HUGE db with many types of queries that relational DB's benefit you from.

it's just so easy to be able to put data in as json and get it out as json.
 

Graze

Senior member
Nov 27, 2012
468
1
0
i've used sql and mongo for professional webapps, and i'd pick mongo over sql any day of the week as long as the db does not need to be scalable and won't be a HUGE db with many types of queries that relational DB's benefit you from.

it's just so easy to be able to put data in as json and get it out as json.

Might go in and out as Json but it might not have been the same data you put in when it comes out. :whiste:
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,560
4,473
75
Might go in and out as Json but it might not have been the same data you put in when it comes out. :whiste:

What exactly do you mean by this? :confused: Are you saying that there's a problem with the Java-object-to-JSON conversion and back? Or are you saying that Mongo is buggy?
 

purbeast0

No Lifer
Sep 13, 2001
53,452
6,299
126
The latter.

been using mongo for about 1.5 years now professionally and have never experienced this. any data issues is always our (engineers) faults for writing faulty code.

we use a groovy backend so it's really easy to go to/from the client -> server -> db -> server -> client with hardly any data transformation.
 

KentState

Diamond Member
Oct 19, 2001
8,397
393
126
What you described is relational and structured so I would stick with SQL and let the database handle RI.
 

beginner99

Diamond Member
Jun 2, 2009
5,312
1,749
136
postgresql and don't turn back. If you need to store schema-less data you can use their JSONB column, it's pretty awesome.

this. JSONB feature of PostgreSQL basically made any NoSQL obsolete.

/end thread

NoSQL might have it's uses in certain niches which include being a web site with traffic in the 10k+ requests per second category. And even then I would go with a relational DB first. Note that Wikipedia runs on MySQL (+ memcached) and has no speed issues at all.