5.2 Compare and contrast various database structures.
📘CompTIA ITF+ (FC0-U61)
A non-relational database is a type of database that does not use the traditional table structure used in relational databases. Instead of storing data in rows and columns, non-relational databases store data in different flexible formats.
These databases are often called NoSQL databases. The term NoSQL means “Not Only SQL”, which indicates that these databases do not rely only on the SQL relational model.
Non-relational databases are commonly used in modern IT systems where:
- Large amounts of data must be stored
- Data structure may change frequently
- High performance and scalability are required
- Applications handle semi-structured or unstructured data
Examples of systems that use non-relational databases include:
- Web applications
- Mobile applications
- Cloud platforms
- Logging systems
- Content management systems
- Real-time analytics systems
Key Characteristics of Non-Relational Databases
Non-relational databases typically have the following characteristics:
Flexible schema
- Data structure does not have to be fixed in advance.
- Different records can contain different fields.
High scalability
- Designed to scale across many servers.
- Often used in distributed systems and cloud environments.
High performance
- Optimized for fast reading and writing of data.
Large data handling
- Suitable for applications that store very large datasets.
For the CompTIA ITF+ exam, two common types of non-relational databases you should understand are:
- Key/value databases
- Document databases
Key/Value Databases
A key/value database stores data as pairs consisting of a key and a value.
- Key – a unique identifier used to find the data
- Value – the actual data associated with that key
This structure is one of the simplest database models.
Structure of a Key/Value Database
The database stores entries like this:
| Key | Value |
|---|---|
| user_1001 | {username: “admin”, role: “administrator”} |
| session_4582 | {status: “active”, timeout: “30 minutes”} |
| config_theme | {color: “dark”, layout: “standard”} |
In this model:
- The key must be unique
- The value can contain almost any type of data
- The database retrieves the value by searching for the key
This works similarly to a dictionary or lookup table in programming.
How Data Is Retrieved
To retrieve data from a key/value database:
- The application provides the key
- The database searches for that key
- The associated value is returned
Example in an IT system:
Key: session_4582
Value: {status: "active", user_id: 1001}
The application asks the database for session_4582, and the system immediately returns the stored data.
Common IT Uses of Key/Value Databases
Key/value databases are widely used in IT environments for:
Session management
- Storing login session information for users in web applications.
Application caching
- Storing frequently accessed data to improve performance.
Configuration storage
- Saving application settings or system configurations.
Real-time data lookup
- Quickly retrieving data using unique identifiers.
Example IT environment:
A web application server may store active user sessions in a key/value database so the system can quickly check whether a user session is valid.
Advantages of Key/Value Databases
Very fast data access
- Direct lookup using the key.
Simple structure
- Easy to implement and maintain.
Highly scalable
- Can distribute data across many servers.
Flexible value storage
- Values can contain many types of data.
Limitations of Key/Value Databases
Limited querying capability
- Data is usually retrieved only by key.
No complex relationships
- Cannot easily model relationships between data elements.
Less structured data control
- There is usually no enforced schema.
Summary of Key/Value Databases
Key/value databases:
- Store data as key–value pairs
- Provide very fast lookup performance
- Are commonly used for caching, session storage, and configuration data
- Do not support complex queries or relationships
Document Databases
A document database stores data as documents instead of rows in tables.
Each document contains structured data, usually written in formats such as:
- JSON (JavaScript Object Notation)
- BSON
- XML
Documents contain fields and values, similar to objects in programming.
Structure of a Document Database
Each record is stored as a document.
Example document:
{
"user_id": 1001,
"username": "admin",
"email": "admin@example.com",
"roles": ["administrator", "developer"],
"account_status": "active"
}
In a document database:
- Each document represents a complete data record
- Documents are stored in collections
- Collections are similar to tables in relational databases
Document Database Components
Document
- The main unit of data storage.
- Contains multiple fields and values.
Field
- A data attribute within the document.
Collection
- A group of related documents.
Example structure:
Collection: usersDocument 1
Document 2
Document 3
Unlike relational tables, documents in the same collection can have different fields.
Example:
Document A
{
"user_id": 1001,
"username": "admin"
}
Document B
{
"user_id": 1002,
"username": "developer",
"permissions": ["read", "write"]
}
Both documents are stored in the same collection even though their structures differ.
How Document Databases Are Used in IT
Document databases are widely used in systems that handle structured and semi-structured data.
Common IT uses include:
Web application data storage
- Storing user profiles and application data.
Content management systems
- Storing articles, pages, and metadata.
API-based systems
- Storing JSON data returned by APIs.
Cloud-based applications
- Managing application data in distributed environments.
Example IT scenario:
A web application may store user profiles as documents. Each user profile document may include:
- Username
- Permissions
- Preferences
- Login history
Because document databases allow flexible fields, each user document can store different types of information.
Advantages of Document Databases
Flexible schema
- Fields can vary between documents.
Easy to store structured data
- Works well with JSON-based applications.
Scalable architecture
- Suitable for distributed cloud systems.
Good performance for large datasets
- Efficient for modern web and application workloads.
Limitations of Document Databases
Less strict data consistency
- Structure is not always enforced.
More difficult to enforce relationships
- Relationships between documents must often be handled by the application.
Not ideal for complex relational queries
- Systems that rely heavily on joins may work better with relational databases.
Summary of Document Databases
Document databases:
- Store data as documents instead of tables
- Use JSON-like structures
- Organize documents into collections
- Allow flexible schemas
- Are commonly used in web, cloud, and API-driven applications
Key/Value vs Document Databases
| Feature | Key/Value Database | Document Database |
|---|---|---|
| Data structure | Key–value pairs | Documents (JSON/XML) |
| Complexity | Very simple | More complex |
| Query capability | Mostly by key only | More advanced queries |
| Schema | No schema | Flexible schema |
| Data organization | Key and value | Collections and documents |
| Common IT uses | Caching, session storage, configuration data | Web apps, content systems, API data |
Key Points for the CompTIA ITF+ Exam
You should remember the following concepts:
Non-relational databases
- Do not use traditional tables and rows.
- Often called NoSQL databases.
- Designed for flexibility, scalability, and high performance.
Key/value databases
- Store data as key–value pairs.
- Provide very fast lookup using keys.
- Commonly used for session storage, caching, and configuration data.
Document databases
- Store data as documents (JSON or similar formats).
- Documents are grouped into collections.
- Allow flexible data structures and are widely used in modern applications.
