The Relational DBs (RDB)
Tags: database, aws, terraform, bigdata
Published: 2022-08-14 16:36:00

**What is a Relational DB?**  

A relational database is categorized as a database that focuses on the collection of data entry points and the relationship between them. 

**How does one know when to choose a Relational DB?**

If you have the knowledge about your data entry points relationship with one and another, and have an uncomplicated course of action of representing the data in tables, then RDB is your best option. 

 
**What are some industries RDB use cases?**

- Traditional applications,  
- Enterprise resource planning (ERP),  
- Customer relationship management (CRM),  
- Ecommerce 
- Lift and shift 

![industries](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/boetx7ibjac7rembc4fx.png)

**Now that we have a general idea of RDB let us continue drilling deeper and let us explore and build AWS RDB resources:**

- Amazon RDS 
- Amazon Aurora 
- Amazon Redshift

**What is Amazon RDS?** 

> Amazon Relational Database Service (Amazon RDS) is a managed service that makes it easy to set up, operate, and scale. 

 > A relational database in the cloud. It provides cost-efficient and resizable capacity, while managing time-consuming database administration tasks, freeing you up to focus on your applications and business. 
 

**Amazon RDS gives you access to the capabilities of familiar SQL flavors such as:**

- MySQL 
- MariaDB 
- Oracle  
- SQL Server 
- PostgreSQL database 

**What is Amazon Aurora?**

> Amazon Aurora is a modern relational database service offering performance and high availability at scale, fully open-source MySQL- and PostgreSQL-compatible editions, and a range of developer tools for building serverless and machine learning (ML)-driven applications.

**What is Amazon Redshift?** 

> Amazon Redshift is a fully managed, scalable cloud data warehouse that accelerates your time to insights with fast, easy, and secure analytics at scale.

**Let us see some important characteristics about these 3 RDBs**

**Amazon-RDS**
```
Performance:

- General Purpose Storage : 3 IOPS * each GB.
- Burst capacity: 3,000 IOPS
- Provisioned IOPS storage:  40,000 IOPS *  each RDS instance. 
- Formula: (Credit balance)
Burst duration =  ---------- (Burst IOPS) - 3*(Storage size in GiB)

Scalability:

- Horizontal
- Vertical 

Availability:
 
- Multi-AZ service level agreement: 99.95% up every month

Security:

- Encryption of data at rest using KMS
- Encryption of data in transit using SSL/TLS
- Access Control using IAM
- Network Isolation and Database Firewall using VPC and industry-standard encrypted IPSec VPN
- Database activity streams beyond external security threats providing a real-time data stream of the database activity in 
your relational database

```

**Amazon-Aurora**

```
Performance:

- 5x throughput of standard MySQL
- 3x of standard PostgreSQL
- Auto-scales up to 128 TB per database instance

Scalability:

- The minimum storage is 10 GB
- Automatically grow, up to 128 TB, in 10 GB increments with no impact on database performance
- Scale out up to 15 read replicas

Availability:

- Fault tolerant
- Self-healing storage
- Automatically divides your database volume into 10 GB segments spread across many disks
- Six copies of data across three AZ's
- Continuous backup to Amazon S3

Security:

- Uses SSL (AES-256) to secure the connection between the database instance and the application
- Network isolation
- Encryption at rest and in transit 

```
**Amazon-Redshift**

```
Performance:

- Massively parallel processing
- Columnar data storage
- Data compression
- Query optimizer
- Result caching
- Compiled code
- 10x better performance than traditional databases
- Automatic Table Optimization (ATO)
- ATO increases cluster performance by 24% and 34% using the 3 TB and 30 TB versus a cluster without ATO 

Scalability:

- Petabyte-scale data warehouse

Availability:

- The cluster node is replaced automatically in case of node failure detection
- Data is backup into S3

Security:

- Built-in AWS IAM integration
- Identity federation for single-sign-on (SSO)
- MFA
- Column level access control
- Row-level security
- Encrypts and keeps your data secure in transit and at rest

```

**Now let us see some limitations to consider:**

**Amazon RDS:**
```

- Read replicas per region: 5 
- Reserved DB instances per region: 40 
- Rules per security group per region: 20 
- Security groups per region: 25 
- Security groups (VPC) per region: 5 
```
**Amazon Redshift:**
```

- AWS accounts that you can authorize to restore a snapshot per snapshot: 20 
- Concurrency level (query slots) for all user defined manual WLM queues: 50 
- Concurrency scaling clusters: 10 
- Nodes: 200 
- Schemas in each database per cluster: 9,900 
- Security groups: 20 
- Snapshots: 20 
```
**Amazon Aurora:**
```
- Authorizations per DB security group per region: 20 
- Custom engine versions per region: 40 
- DB cluster parameter groups per region: 50 
- DB clusters per region: 40 
- DB instances per region: 40 
- DB subnet groups per region: 50 
- Data API HTTP request body size per region: 4 MGB 
```
_Please note that some of these limitations are adjustable and others are not._ 

Oh, right it is building :construction_worker: time let us build these 3 databases using Terraform

![3DB's](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zcs0rpnvoklsbmy94w8.png)
 

[Find the Terraform repo and directions for this project here](https://github.com/ValAug/aws-databases-terraform)

**Terraform code previous:**

```
#---aurora/main--

resource "aws_rds_cluster_instance" "cluster_instances" {
  count              = 1
  identifier         = "aurora-cluster-example-${count.index}"
  cluster_identifier = aws_rds_cluster.my_rds.id
  instance_class     = "db.r4.large"
  engine             = aws_rds_cluster.my_rds.engine
  engine_version     = aws_rds_cluster.my_rds.engine_version
}

resource "aws_rds_cluster" "my_rds" {
  cluster_identifier = "aurora-cluster-example"
  availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
  database_name      = "USES-YOUR-OWN-DB-NAME-HERE"
  master_username    = "username"
  master_password    = "Always_use_complex_password"
}
```
**Diagram**

![Diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yoax5ymxzaua0ulrpc5x.png)

**References:**
```
 

https://aws.amazon.com/rds/features/security/ 

https://aws.amazon.com/redshift/faqs/ 

https://aws.amazon.com/rds/aurora/faqs/ 

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Limits.html 

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_Limits.html 

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_Limits.html 
```