AWS SAA-C02 Databases

Relational vs Non Relational

Structured data

transactional and analytical. Relational or non relational.

Semi structured

e.g. xml. But flexible, updated withing the requirement to change the schema for every record in the table. Non relational stores, e.g. XML,. JSON, email

Unstructured

not organized. e.g. key value pairs, lots of irrelevant information. e.g. text messages, docs, videos. Files in file store or data lake.
often combined, e.g. point of sale system produces structured data, integrated with clickstream data form the website in XML. Need to bring together to query.

RDS

more custom option: EC2 instance with database

Setup Wordpress on MySQL

Set up MySQL db, free tier Set up EC2 instance

# Install WordPress on EC2 using RDS MySQL DB
yum update -y
amazon-linux-extras install -y php7.2 yum install -y httpd
systemctl start httpd
systemctl enable httpd
cd /var/www/html
wget https://wordpress.org/latest.tar.gz tar -xzf latest.tar.gz
cp -r wordpress/* ./
chmod -R 755 wp-content
chown -R apache:apache wp-content
yum install php-mbstring -y
systemctl restart httpd
systemctl restart php-fpm
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all- languages.tar.gz
mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1
rm phpMyAdmin-latest-all-languages.tar.gz

Go to public I{ address and see wordpress installation screen Put in database urn in wordpress setup page SSH to the EC2 instance, create wordpress wp-config.php file in EC2. Give site title

Install PHP etc

# Install PHP MyAdmin
yum install php-mbstring -y
systemctl restart httpd
systemctl restart php-fpm
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1 rm phpMyAdmin-latest-all-languages.tar.gz

# Edit config:
nano config.sample.inc.php #add database host name

# Add text (enter RDS endpoint):
$cfg['Servers'][$i]['host'] = 'RDS MYSQL ENDPOINT'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['AllowNoPassword'] = false; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['extension'] = 'mysqli';

# Copy sample file over live file:
cp config.sample.inc.php config.inc.php
service httpd restart

Go to ip address/phpmyadmin to get MySQL database manager.

Multi AZ database

Multi AZ:

setup: just choose setting to make multi AZ. Takes time initially. Demo with reboot, wordpress site goes to replica.

Read replica

Read replica: Asynchronous replication. Separate endpoint, so you can use it. Can be cross region! Can promote to writable db.

Multi AZ read replicas

If you need fail over on read replicas.. If you fail over to a rr, then the rr copy becomes the OLTP replica.

RDS encryption

Snapshots

Migration

Aurora

Aurora replicas vs MySQL replicas

Aurora replica

Aurora Cross region replica

MySQL replicas

Aurora fault tolerance

Multi AZ, multi copies in an AZ, so 6 min copies of the data

Aurora setup

provisioned (defined scale) or serverless (autoscaling) tiers control the order of failover can enable backtrack

Cross region read replicas: need to enable bin logging. Promote: makes a read replica a primary, stops and reverses replication.

Global database setup

Aurora multi master

Aurora Serverless

Dynamo DB

Features

DynamoDB table setup

DynamoDB Streams

DynamoDB Accelerator (DAX)

Look at python and DAX example

Global table

Elasticache

Fully managed, in memory datastores Use when want to improve latency and throughput for read intensive apps. best for OLAP 2 different options

Redis

Redis AUTH command: requires users to have a token (password) before allowing clients to execute commands.

MemCacheD

Need to write code to use this effectively.

Redshift

Document DB

Neptune

Gremlin query to find Howard's friends friends

g.V().has('name', 'Howard').out('friend').out('friend').values('name')

QLDB

Timestream