Databases in the development process

Databases are used to persist data

▪ Users can create, read, update or delete entries in a database

▪ Also called CRUD operations

▪ Developers need a database for local development

● Connect to a development database to develop the new features

● Connect to a test database to test the new feature with realistic data

🟢 There are 2 ways for developers to work with DB

▪ OPTION 1

● Each developer installs DB locally

● Each developer has own DB with own test data

Advantages & Disadvantages

✅ Can't mess up someone else's test

❌ DB data start from empty DB | need realistic test data

❌ Install and setup DB for EVERY developer

▪ OPTION 2

● Shared DB hosted remotely

Advantages & Disadvantages

✅ No need for local installation | start coding right away

✅ Test data available right from the start

❌ Can't play around without affecting others!

🟢 Configure Database Connection

How does the application talk to the database?

The DB connection is configured in the application's code

Each programming language has a library/module for DB connection

Better: Do not hardcode database connection data in source code

Best Practice: DON'T check in credentials in code

✅ Define only variables in code

✅ Set endpoint and credentials from outside for each environment (for example dev, test, prod)

✅ Depending on environment (dev, test, prod) connects to different DB!

The way to do this, is to pass environment variables on application start-up

How to pass environment variables:

  1. From Command Line

  2. Configure in code editor

  3. Use properties/configuration files

The best option is to pass them via a properties or configuration file

In a Java/Spring application, you can define the values in a Spring properties file:

Databases in Production

Application connects to database

This means database needs to be available, when application starts

So before application is deployed, we need to install and configure database

🟥 Data is important, so we need to secure them:

✅ Replicate database

✅ Do regular backups

✅ Make sure it performs under high load when many users accessing the application

This may be done by:

System Administrator

Database Engineer

DevOps Engineer

Last updated