0% found this document useful (0 votes)
3 views

Bonus - Databases Handout

The document provides an overview of databases in software development, highlighting CRUD operations and the importance of database connections in applications. It discusses two approaches for developers to work with databases—local installations versus shared remote databases—and emphasizes best practices for configuring database connections using environment variables. Additionally, it categorizes various types of databases, including key-value, relational, document, graph, and search-engine databases, outlining their characteristics and suitable use cases.

Uploaded by

leandroguim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Bonus - Databases Handout

The document provides an overview of databases in software development, highlighting CRUD operations and the importance of database connections in applications. It discusses two approaches for developers to work with databases—local installations versus shared remote databases—and emphasizes best practices for configuring database connections using environment variables. Additionally, it categorizes various types of databases, including key-value, relational, document, graph, and search-engine databases, outlining their characteristics and suitable use cases.

Uploaded by

leandroguim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

DEVOPS

BOOTCAMP
Databases
Databases are used to persist data

create

read

update

delete

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


Also called CRUD operations
Database in software development process - 1

Developers need 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
...
Database in software development process - 2

2 ways for developers to work with DB

Each developer installs DB locally


can't mess up someone else's test DB data
Option 1 Each developer has own DB with own
test data start from empty DB | need realistic test data

install and setup DB for EVERY developer

Ideal solution: have both!

Option 2 Shared DB hosted remotely no need for local installation | start coding right away

test data available right from the start

can't play around without affecting others!


How does the application
Configure Database Connection - 1 talk to the database?

The DB connection is configured in the application's code


Each programming language has a library/module for DB connection

WHICH database to talk to HOW to AUTHENTICATE with that DB


You have to tell the library:
= =

Database Endpoint Credentials

Example: Java Code connecting to a Mysql database


Configure Database Connection - 2

Better: Do not hardcode database Best Practice: DON'T check in


connection data in source code credentials in code

Define in 1 place as environment variables

Configure DB connection from OUTSIDE

1. Define only variables in code


2. Set endpoint and credentials from outside for each environment
(for example dev, test, prod) DEV TEST PROD
3. Depending on environment (dev, test, prod) connects to different
DB!
Configure Database Connection - 3

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

1) From Command Line


How to pass envrionment variables:

2) Configure in code editor

3) Use properties/configuration files

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


Configure Database Connection - 4.1

In a Java/Spring application you can define the values in a


Spring properties file:

3 property files for each environment

Values defined in a properties file

Usage in Java code


Configure Database Connection - 4.2

Nodejs application with configuration file:

Using a configuration file is:

cleaner

more transparent
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 PROD PROD

Data is important so we need to secure them: This may be done by:

1. Replicate database
2. Do regular backups
3. Make sure it performs under high load System Database DevOps
Administrator Engineer Engineer
Database Types - 1

Key Value Databases Relational Databases Graph Databases

Wide Column Databases Document Databases Search Databases

Many different database types available

They have different characteristics for different use cases

Each of them has benefits and disadvantages


Database Types - 2 Key Value Databases

Examples:

Redis Memcached etcd from Kubernetes

Characteristics Best for:


very fast
Data is saved in key-value pairs Caching
unique key Message Queue limited storage

no joins no primary database


in-memory
Database Types - 3 Wide Column Databases

Examples:

Characteristics Best for:


scalable
A two-dimensional key-value store Time-Series
no joins
Data is saved in tables, rows and IoT-Records
columns limited compared to relational DB
Names and format can vary from
no primary DB
row to row (schema-less)
Queries similar to SQL
Database Types - 4 Document Databases

Examples:

Collection:

MongoDB DynamoDB CouchDB

Characteristics Best for:


faster to read
Data is stored as JSON-like Mobile Apps
easy to get started
documents Game Apps
Schema-less CMS primary database
No joins Most Apps
slower writes
Denormalized
graphs
Database Types - 5.1 Relational Databases

Examples:

Characteristics Best for: ACID

Data is stored in Tables, Rows and structured data easy to get started
Columns
primary database
Schema (schema and data types need
to be created first) difficult to scale

Normalized to avoid duplicated data unstructured data


Most used in industry
Database Types - 5.2 Relational Databases

ACID = Atomicity, Consistency, Isolation, Durability

No half-changes are updated in database

Either ALL changes get applied or NON

SQL vs No-SQL
Because relational or SQL databases are so popular,
often we talk about SQL vs No-SQL, meaning all the other
database types, which are schema-less
Database Types - 6 Graph Databases

Examples:

Neo4j Dgraph

Characteristics Best for:


easier to query
Data is stored as Nodes and Relationships Graphs
instead of tables or documents Patterns
Directly connect Entities
Edges are the Relationships
Database Types - 7 Search-Engine Databases

Characteristics
Dedicated to the search of data
Examples:
Optimized for dealing with data
ElasticSearch Solr
Full-text search in efficient and fast way
Similar to document-orientated database

Usage of indexes
Wrap Up

Choose database type based on your application needs

Or Combinations

For most of data Relational

For example: To handle fast search Search Engine

Cache Key Value

You might also like