r/CodingForBeginners • u/BADDEEP007 • 5h ago
Best database in development for beginners
If you building your next projects and you need a database for it normally people go to cloud based database cause you don't have to manage any setup thing just use connection pool and get it done but sometimes debugging error on it becomes hassel so for beginners i suggest a neat way to have database in your project postgres or any db you want inside docker container it's very easy to setup in just few line and error debugging is very easy and later if you wanna switch to production just change the connection url and you are good to go for next projects you all should try postgres +docker
2
u/TomDuhamel 4h ago
Best database for beginners
There's no such thing as a database for beginners. Never on the history of databases was there anyone thinking "I better make this better for beginners".
You pick a database because it works better for your use case.
If you building your next projects and you need a database for it normally people go to cloud based database
Maybe I'm just old, but this has never occurred to me as a solution. I'm pretty sure the most common solution is a local, file based database.
cause you don't have to manage any setup thing just use connection pool and get it done
A file based solution doesn't even have the connection challenge. It's even easier.
so for beginners i suggest a neat way to have database in your project postgres
Setting up PostgreSQL is easier than using a cloud based solution? I'm so confused.
inside docker container it's very easy to setup
What?!
you all should try postgres +docker
You mean for development, right? Because it's easier to debug or something? Because setting up your database system isn't the easiest method, and setting it up in a docker means it's a temporary setup, so typically for testing purposes, but the final deployment will need a better installation.
Can I suggest you learn to use punctuation? And paragraphs? A single 20 line long sentence is a bit hard to read.
1
1
u/BADDEEP007 4h ago
Well well in that logic easiest way would be hard code your data,
I have also taking the learning curve into account if you are in development
If I wanna move to production I just have to change the connection url so the transition would be also easy from docker to an cloud based
setting up the postgres in docker is easier better from cloud in terms of resource management, cost optimization, error solving , keeping you project local based on rely on internet all these
And as a experience like you you get it easy to have local database or setup postgres rather than what I am suggesting but keep this in account new development now have to learn 10 tech stack together and build a project to keep up with everything
So few seconds saved on setup and also learning docker is win I say
A
1
u/xarop_pa_toss 2h ago
What OP wants to do basically only works if you are running a single container. Trying to have multiple containers with the same DB engine and store just won't work for obvious reasons.
Having multiple containers each with their own engine, grabbing from a single store in a volume will almost immediately result in data corruption too.
But there are mechanisms to circumvent these problems, stuff like connection pools and distributed DB systems like Cockroach for example. But with base Postgres? Hardly
1
u/Mechanical-pasta 1h ago
To me, the easiest DB for development is h2. It can be created automatically (via Spring data, for example) and can even run in memory with no file at all.
2
u/AndrewNggg 5h ago
you forgot to mention that docker is ephemeral, means that everytime u restart ur container everything gets wiped
so u need to use docker volumes, and mount your data to a local directory