Database Flashcards

1
Q

How does partitioning and sharding contribute to database scalability?

A

Partitioning involves dividing a large table into smaller partitions based on a criteria like date range, while sharding involves distributing data across multiple servers. This allows for more efficient data storage and retrieval, improving scalability by distributing the workload.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some optimization techniques for improving database performance?

A

Optimization techniques include caching frequently accessed data, optimizing queries using indexes and execution plans, and using data compression to reduce storage costs and improve I/O performance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What security measures are important for protecting a database?

A

Important security measures include implementing role-based access control (RBAC), encrypting sensitive data at rest and in transit, and performing regular security audits and penetration testing to identify and mitigate vulnerabilities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of backup and recovery procedures for a database?

A

Backup and recovery procedures are essential for ensuring data durability and recoverability in case of failures or disasters. They involve taking regular backups of the database and implementing procedures for restoring data from backups when needed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can database scalability be achieved?

A

Database scalability can be achieved through vertical scaling (upgrading hardware resources) and horizontal scaling (adding more database servers and distributing data across them using techniques like partitioning and sharding).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some common data types used in SQL databases?

A

Common data types in SQL databases include INTEGER (for whole numbers), VARCHAR(n) (for variable-length character strings), DATE (for dates), and DECIMAL(p, s) (for fixed-point numbers).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does a JOIN operation work in SQL?

A

A JOIN operation combines rows from two or more tables based on a related column between them. Common types of JOINs include INNER JOIN (returns rows that have matching values in both tables) and OUTER JOIN (returns all rows from one or both tables, with NULL values where no match is found)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a primary key in SQL, and why is it important?

A

A primary key is a unique identifier for each row in a table. It ensures data integrity by preventing duplicate rows and is used as a reference point for relationships between tables. Primary keys are typically implemented using a UNIQUE constraint.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are some common NoSQL database types?

A

Common types of NoSQL databases include document databases (e.g., MongoDB), key-value stores (e.g., Redis), column-family stores (e.g., Cassandra), and graph databases (e.g., Neo4j).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does document-based storage differ from relational storage?

A

Document-based storage, commonly used in NoSQL databases like MongoDB, stores data in flexible, schema-less documents (e.g., JSON or BSON), allowing for nested structures and dynamic schemas. In contrast, relational storage in SQL databases requires predefined schemas with structured tables and relationships between them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is eventual consistency in NoSQL databases?

A

Eventual consistency is a consistency model used in some NoSQL databases where data updates may be propagated asynchronously to multiple nodes, resulting in temporary inconsistencies. However, over time, all replicas will converge to a consistent state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is CAP theorem, and how does it relate to NoSQL databases?

A

The CAP theorem states that in a distributed system, it’s impossible to simultaneously achieve consistency (all nodes have the same data), availability (every request receives a response), and partition tolerance (the system continues to operate despite network partitions). NoSQL databases often prioritize partition tolerance and availability over strong consistency, which is reflected in their design choices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly