How to create relational database in AWS
Tags: aws, mysql
Published: 2022-04-16 09:34:43

SQL is a programming language used to manage data in a relational database. A relational database is a collection of data with defined relations between data. I used AWS RDS for the relational database setup and saving data. We can set up RDS in AWS free tier account. If you want to learn how to do relational database setup in AWS RDS, continue reading this blog. Open AWS console and search for RDS. Click on create the database.

![create database button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz7bnw7ct2sz4g93o9xz.png)

Select standard creates so that we can configure the database according to our requirements. MySQL is one of the most used relational database management systems. Use MySQL as the engine. RDS is available with the free tier account too so we will use the free tier as the template. 

![template](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/he77ifxnjy10j24locdg.png)
You will require a user name and password to connect to the database. Next step, we have to set up the database name, user name, and password in the settings. Save the user name and password securely. We can only use burstable classes in the free tier account. I used the t2 micro because it is enough to try a relational database in the personal project and the cheapest. 

**Storage**
General-purpose SSD storage is best to handle the high load. According to your requirement, you can set the allocated storage. 20 GiB is enough for my project. 

![storage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d6cpu6s0y0cc26cfku3o.png)
RDS support autoscaling. If storage consumption reaches a threshold, storage will increase automatically. Autoscaling needs a maximum storage threshold. It should be at least 10% more than the currently allocated storage. RDS will increase the storage up to this threshold value only.

**Availability and durability**

Multi-AZ deployment is recommended for production. In an Amazon RDS Multi-AZ deployment, Amazon RDS automatically creates a primary database (DB) instance and synchronously replicates the data to an instance in a different AZ. When it detects a failure, Amazon RDS automatically fails over to a standby instance without manual intervention.

**Connectivity**

Select VPC where you want to create a DB instance. If you have not created the subnet group then you need to create one subnet group in the same VPC. 
Click on subnet groups from the sidebar. Give an appropriate name to subnet groups. Select the VPC from the dropdown. Each DB subnet group should have subnets in at least two availability zone. 

![connectivity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jr9s3wg0g8l54ey8rqdg.jpg)

If you don't have the subnet in at least two availability zone in the selected VPC then you have to first create two subnets in at least two availability zone in the selected VPC.
Select public access yes so that devices outside the VPC can connect to your database. VPC security group require to allow access to your database. You can edit inbound rules and allow access to your database.

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

**Database Authentication**

I use password authentication. If anyone needs to connect to the database, then use the user name and password to connect to the database.

After the successful creation of the database, you can see the endpoint and port in the connectivity and security section. It requires connecting to the database. For example, if you want to connect to database from mysql workbench then ednpoint will become host name, port will be same and user name and password will be the user name and password that you provided while creating database.

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