Databases Flashcards
Explain the difference between SQL and NoSQL databases
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
What are some advantages and disadvantages of SQL
- ensure data consistency
- ensure ACID compliance
- doesn’t handle unstructured data as well
What are some advantages and disadvantages of NoSQL
- flexible data models
- handles unstructured and semi-structured data
- could have issues with data consistency
What scenarios would you recommend using SQL over NoSQL
- 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
Describe the ACID properties in database transactions
- 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
What trade-offs might be involved in maintaining ACID properties?
- performance overhead due to locking and serialization
- affects scalability in high-concurrency scenarios
Explain the concept of indexing in databases
Indexing accelerates data retrieval by creating efficient access paths
What are the different types of database indexes?
Some common indexes are B-tree and hash indexes
How does indexing enhance query performance?
Indexing makes columns faster to query by creating pointers to where data is stored within a database
What factors should be considered when choosing columns to index?
- selectivity (uniqueness)
- query patterns
- data modification frequency
- Indexing trade-offs include increased storage overhead and potential maintenance overhead due to updates.
Discuss the importance of database normalization
- reduces data redundancy by organizing it into related tables while adhering to specific normal forms
What are the different normal forms?
- 1NF, 2NF, 3NF, BCNF, etc.
- provide guidelines for reducing data duplication
How does normalization contribute to efficient data storage and maintenance?
- minimizes anomalies
- maintains efficient query performance
Are there scenarios where denormalization might be preferable?
- to meet specific query performance requirements
- example: creating redundant fields for improved read performance in reporting systems
What does CAP stand for?
Consistency, Availability, and Partition Tolerance