Concepts
Relational databases are structured and use tables to store data. They rely on a schema that defines the table’s structure, including the columns and data types. They use SQL (Structured Query Language) for querying and manipulating data. The primary feature of relational databases is the ability to handle structured data with relationships between the various entities stored in the database.
In AWS, the main managed relational database service is Amazon RDS (Relational Database Service). It supports various database engines, such as PostgreSQL, MySQL, MariaDB, Oracle, and SQL Server. Additionally, you have Amazon Aurora, an AWS proprietary database engine compatible with MySQL and PostgreSQL, known for its performance and reliability.
Example: Amazon RDS – MySQL
Create an RDS instance using MySQL database engine:
aws rds create-db-instance \
–db-instance-identifier mydbinstance \
–db-instance-class db.t2.micro \
–engine mysql \
–allocated-storage 20 \
–master-username masterawsuser \
–master-user-password masteruserpassword
Non-Relational Databases
Non-relational databases, also known as NoSQL databases, are more flexible and designed to handle a wide variety of data models, including key-value, document, wide-column, and graph formats. They often provide features that enable horizontal scaling to handle large volumes of data with high performance and are best suited for unstructured or semi-structured data.
Amazon provides several NoSQL services, with Amazon DynamoDB being the most popular. It is a key-value and document database service that offers single-digit millisecond performance at any scale. Other options include Amazon DocumentDB for document data models and Amazon Keyspaces (for Apache Cassandra) for wide-column stores.
Example: Amazon DynamoDB
Create a DynamoDB table:
aws dynamodb create-table \
–table-name UsersTable \
–attribute-definitions \
AttributeName=UserID,AttributeType=S \
–key-schema AttributeName=UserID,KeyType=HASH \
–provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5
Comparison between Relational and Non-relational Databases
Aspect | Relational Database | Non-Relational Database |
---|---|---|
Data Structure | Structured data (tables with rows and columns) | Unstructured or semi-structured (documents, key-value, columnar, graph) |
Query Language | SQL | Varies by type (e.g., JavaScript-like queries for DynamoDB) |
Flexibility | Schema must be defined upfront; changes can be difficult | Schema-less or have dynamic schemas, allowing for easy modifications |
Relationships | Relationships between data are defined using foreign keys | Typically handle related data differently, such as embedding documents or using references |
Transactions | Strong support for ACID transactions | Varies; some support ACID properties, while others prioritize performance and scalability |
Scaling | Vertical scaling (increasing the capacity of a single machine) | Horizontal scaling (adding more machines to a distributed system) |
Use Cases | Traditional applications with a clear structure and consistent data types | Big data applications, real-time web apps, IoT, and when a flexible schema is required |
As an AWS Certified Developer – Associate candidate, you should be comfortable choosing between these database services based on the application requirements and recognizing the trade-offs related to performance, consistency, scalability, and ease of management. Understanding when to use Amazon RDS, Amazon Aurora, or Amazon DynamoDB and how to perform basic operations, such as creating and configuring these database services, is crucial for the exam.
It’s also imperative to be familiar with best practices for securing databases in AWS, implementing backup and recovery strategies, and understanding the costs associated with managed database services. With this knowledge, you will be well-prepared for questions regarding data storage on the DVA-C02 exam.
Answer the Questions in Comment Section
True or False: Relational databases store data in tables with predefined schemas.
- A) True
- B) False
Answer: A) True
Explanation: Relational databases use a structure that allows us to identify and access data in relation to another piece of data in the database. They are based on a table structure that involves rows and columns, with a strict, predefined schema.
Which AWS service is a fully managed non-relational database service?
- A) Amazon Redshift
- B) Amazon RDS
- C) Amazon Aurora
- D) Amazon DynamoDB
Answer: D) Amazon DynamoDB
Explanation: Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability.
True or False: Amazon RDS supports automatic backup and database snapshots.
- A) True
- B) False
Answer: A) True
Explanation: Amazon RDS provides automatic backups and allows users to create their own backup snapshots.
What does ACID stand for in the context of relational database transactions?
- A) Atomicity, Consistency, Isolation, Durability
- B) Association, Consistency, Isolation, Durability
- C) Atomicity, Connection, Isolation, Durability
- D) Atomicity, Consistency, Integration, Data
Answer: A) Atomicity, Consistency, Isolation, Durability
Explanation: ACID is a set of properties that guarantee that database transactions are processed reliably. It stands for Atomicity, Consistency, Isolation, Durability.
Which AWS service allows you to run managed relational databases in cloud environments?
- A) AWS Data Pipeline
- B) Amazon DynamoDB
- C) Amazon Redshift
- D) Amazon RDS
Answer: D) Amazon RDS
Explanation: Amazon RDS stands for Relational Database Service and it allows users to create, run, and manage relational databases in the cloud.
True or False: Amazon Aurora is compatible with MySQL and PostgreSQL.
- A) True
- B) False
Answer: A) True
Explanation: Amazon Aurora is designed to be compatible with MySQL and PostgreSQL, allowing users to use existing code, tools, and drivers.
Which characteristic is commonly associated with non-relational databases?
- A) Fixed schema
- B) Less flexible indexing
- C) Support for complex joins
- D) High scalability for large volumes of data
Answer: D) High scalability for large volumes of data
Explanation: Non-relational databases like NoSQL are known for their high scalability, handling large volumes of unstructured or semi-structured data with ease.
True or False: Non-relational databases are better suited for hierarchical data storage.
- A) True
- B) False
Answer: A) True
Explanation: Non-relational databases, especially document-oriented databases like MongoDB, are better suited for hierarchical data storage due to their schema-less and nested structures.
What type of index does Amazon DynamoDB use to support the quick querying of data?
- A) B-Tree Index
- B) Bitmap Index
- C) Global Secondary Index (GSI)
- D) Local Secondary Index (LSI)
Answer: C) Global Secondary Index (GSI) and D) Local Secondary Index (LSI)
Explanation: Amazon DynamoDB allows the creation of Global Secondary Indexes (GSI) for querying on any attribute, and Local Secondary Indexes (LSI) for queries on non-key attributes only in the same table.
True or False: In a non-relational database, each record must have the same fields or structure.
- A) True
- B) False
Answer: B) False
Explanation: Non-relational databases, unlike relational databases, do not require a fixed schema or the same fields for each record, which allows for varying attributes in data.
Which of the following AWS services provides a managed graph database?
- A) Amazon Neptune
- B) Amazon RDS
- C) Amazon Aurora
- D) Amazon DynamoDB
Answer: A) Amazon Neptune
Explanation: Amazon Neptune is a fully managed graph database service, which is optimized for storing billions of relationships and querying the graph with milliseconds latency.
True or False: Amazon RDS can automatically patch the database software running on its instances.
- A) True
- B) False
Answer: A) True
Explanation: Amazon RDS allows for automatic software patching, which means that it can handle necessary database software patches as part of the managed service.
This blog post on relational and non-relational databases was very insightful, especially for the AWS Certified Developer – Associate exam.
Thanks for the detailed explanation! It’s really helpful.
I appreciate the breakdown of when to use relational vs. non-relational databases.
Great post! Quick question: Is DynamoDB considered a non-relational database?
Can someone explain the primary advantages of using relational databases over non-relational ones?
I found the comparison between RDS and DynamoDB extremely helpful!
This was very informative, thank you!
Quick note: The performance benchmarks for DynamoDB seemed a bit dated in the post.