Databases Flashcards

1
Q

Explain the difference between SQL and NoSQL databases

A

SQL
* relational databases
* use structured tables
* use a standardized query language for data manipulation

NoSQL
* more flexible data models
* handling unstructured or semi-structured data

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

What are some advantages and disadvantages of SQL

A
  • ensure data consistency
  • ensure ACID compliance
  • doesn’t handle unstructured data as well
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are some advantages and disadvantages of NoSQL

A
  • flexible data models
  • handles unstructured and semi-structured data
  • could have issues with data consistency
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What scenarios would you recommend using SQL over NoSQL

A
  • SQL for applications requiring transactional integrity, like financial systems
  • NoSQL forsocial media platforms or IoT applications
  • choice depends on factors like data complexity, scalability needs, and transactional requirements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe the ACID properties in database transactions

A
  • Atomicity: ensures transactions are treated as a single unit (all or nothing)
  • Consistency: enforces transactions bring the database from one valid state to another
  • Isolation: ensures transactions are executed independently, preventing interference
  • Durability: guarantees that committed transactions persist even in the face of failures
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What trade-offs might be involved in maintaining ACID properties?

A
  • performance overhead due to locking and serialization
  • affects scalability in high-concurrency scenarios
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Explain the concept of indexing in databases

A

Indexing accelerates data retrieval by creating efficient access paths

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

What are the different types of database indexes?

A

Some common indexes are B-tree and hash indexes

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

How does indexing enhance query performance?

A

Indexing makes columns faster to query by creating pointers to where data is stored within a database

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

What factors should be considered when choosing columns to index?

A
  • selectivity (uniqueness)
  • query patterns
  • data modification frequency
  • Indexing trade-offs include increased storage overhead and potential maintenance overhead due to updates.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Discuss the importance of database normalization

A
  • reduces data redundancy by organizing it into related tables while adhering to specific normal forms
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the different normal forms?

A
  • 1NF, 2NF, 3NF, BCNF, etc.
  • provide guidelines for reducing data duplication
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does normalization contribute to efficient data storage and maintenance?

A
  • minimizes anomalies
  • maintains efficient query performance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Are there scenarios where denormalization might be preferable?

A
  • to meet specific query performance requirements
  • example: creating redundant fields for improved read performance in reporting systems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does CAP stand for?

A

Consistency, Availability, and Partition Tolerance

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

How does the CAP theorem describe the trade-offs between consistency, availability, and partition tolerance in distributed systems?

A

CAP theorum states that in a distributed system, it’s impossible to achieve all three of Consistency, Availability, and Partition Tolerance simultaneously

17
Q

Can you provide an example of a database that emphasizes each aspect of the CAP theorum?

A

MongoDB
* a NoSQL database
* emphasizes consistency and partition tolerance
* ensures data consistency and availability under network partitioning

CassandraDB
* emphasizes availability and partition tolerance
* may occasionally sacrifice strong consistency

18
Q

What is partition tolerance?

A

The ability to continue to work despite any number of communication breakdowns between nodes