0

When to use no-sql database instead of sql ?

What is the useages of no-sql (i.e Mongo db ) database and why i should use it instead of sql one ?

13th May 2019, 12:22 AM
Omar Sherif
Omar Sherif - avatar
1 Odpowiedź
0
NoSQL is nice when the data is less structured. You can add key-value pairs with any values so not every record will have the same data. You don't have to rework the database as often when you change your application. For things that are more structure, SQL is a better solution. For things less structured, NoSQL could be a good choice. Honestly, I think SQL is better for most real databases. But let's say that you want to track users and their browsing history on your site. Anything can be done with either database type. NoSQL can let you be more lazy. Instead of having a rigid field list, you can just throw some key-value pairs into the table as data. You don't have to edit the table to add fields. Using the same example. A NoSQL database could simply have a user. In that user table, you add whatever you want to know about that user as key-value pairs. That could include their browsing history, profile data, and other preferences. That table might look like: name="jerry" email="email@gmail.com" pref1="red" pref2="green" pref3="abc" page1=somedate page2=somedate In a loose structure like that, you don't want to define a bunch of fields in a SQL table. You're just storing a list of random stuff in a single user record. Kind of like a JSON file. But in a SQL table, you would create multiple tables and store the data in those tables. It's more structured, but potentially more work to maintain the database as the app changes. With NoSQL, you can be quick and dirty. Again, I like SQL better. I prefer structure. But I imagine in some cases, such as a game with a ton of objects, a NoSQL table might be easier to implement.
6th Sep 2024, 4:18 PM
Jerry Hobby
Jerry Hobby - avatar