Database concepts Flashcards

1
Q

What’s a relational DB

hint - what does it say about its data (2 bullet points)

A
  1. allows us to identify and access datain relationto another piece of data in the database, e.g. foreign key constraints
  2. designed to store structure data, usually organized as a set of tables with columns and rows
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are 4 important aspects of a relational DB

A
  • supports SQL
  • data integrity
  • supports transactions
  • ACID compliance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s ACID compliance (what does ACID stands for)

A
  • atomicity
    • consistency
    • isolation
    • durability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What’s data integrity (referring to one aspect of a relational DB, 4 bullet points)

A

Data integrity

- overall completeness, accuracy and consistency of data
- use a set of constraints to enforce data integrity
- These include primary Keys, Foreign Keys, ‘Not NULL’ constraint, ‘Unique’ constraint, ‘Default’ constraint and ‘Check’ constraints
- most relation databases also allow custom code to be embedded in triggers that execute based on an action on the database
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Name a few popular relational DB (no need to name all)

A
  • MySQL
  • PostgresSQL
  • Oracle
  • SQL server (microsoft)
  • SQLite - popular open source SQL DB
  • snowflake
  • Amazon Aurora
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain the “A” in ACID

A

Atomicity - a transaction is either all or nothing

All parts of a transaction are executed completely and successfully, or else the entire transaction fails.

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

Explain the “C” in ACID

A

Consistency

  • consistency refers to data integrity, data written as a part of the transaction must adhere to all defined rules.
  • Restrictions include constraints, cascades, and triggers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain the “I” in ACID

A

Isolation

  • each transaction is independent of all other transactions
  • critical to achieve concurrency control
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain the “D” in ACID

A

Durability
- All changes made in the transaction are permanently stored even if the DB fails

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

Why is DynamoDB noSQL

A

DynamoDB is NoSQL in that it does not support SQL. Instead, it uses a proprietary API based on JSON.

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

What’s a noSQL DB

A
  • doesn’t store data in tables but instead in whatever format is best for the type of data being stored
  • designed to contain unstructured data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Give some examples of data that are better to be stored in noSQL DB

A

Loosely defined data like
- email
- videos
- images
- business documents

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

What are several ways to create noSQL DB

hint - what are some ways other than “key value pairs” (4 bullets including key/value)

A
  • key-value stores
  • column-family data stores
  • graph databases
  • document databases
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Name some common noSQL DB

A

MongoDB
IBM Cloundant
Amazon DynamoDB
Apache Cassandra

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

When to use SQL vs noSQL DB

A
  1. structured or unstructured data? - noSQL can work with both
  2. how much data are you storing - noSQL are better for larger vol of data than SQL DB
  3. who’s managing your data - non professionals find SQL DB easier to work with (because they are more familiar with using SQL queries?)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Advantages of using DDB (7 bullets)

A
  • single digit msec performance
  • nearly unlimited throughput and storage
  • automatic multi region replication
  • encryption at rest
  • SLA of 5 9s availability
  • fully managed, auto scale up and down
  • integrated with AWS
17
Q

Optimistic vs pessimistic locking - How do they lock

A

Optimistic locking

When you read a record, take note of a version number (other methods to do this involve dates, timestamps or checksums/hashes) and check that the version hasn’t changed before you write the record back.

Pessimistic locking

Lock the record for your exclusive use until you have finished with it.

18
Q

What fields we can do optimistic locking on

A

Normally use the version field, but can use other fields such as timestamp, checksum, etc

19
Q

Pros and cons for pessimistic locking

A
  • Con - could run into deadlocks
  • Pro - better integrity than optimistic locking
20
Q

When do we use optimistic locking

A

Used in three-tiered architectures where application does not maintain DB locks as connections are taken from a pool.

21
Q

When do we use pessimistic locking

A

Either need a direct connection to DB or or an externally available transaction ID that can be used independently of the connection.