Databases Flashcards

1
Q

What is a transitive dependency?

https://www.lifewire.com/transitive-dependency-1019760

A

A transitive dependency is when A -> B -> C, A has a transitive dependency of C through B. This can be true for databases as well, which is why the 3rd normal form looks to remove all transitive dependencies

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

What is a partial dependency?

https://stackoverflow.com/questions/25747802/partial-dependency-databases

A

A partial dependency is when we have a primary key, maybe a consisting of a natural key used as a primary key, (A,B) -> C, but we can remove B and still get A -> C, meaning A,B is partially dependent on C.

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

What is denormalization? pros and cons

A

denormalization is when we add duplication to a database to reduce join statements and improve query speeds.

pros: less joins, potentially faster queries, potentially fewer tables too
cons: writes are very difficult bc data is in multiple places, the sql update/insert statements are harder to write, we need to increase storage as well

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

What is normalization? pros and cons

A

normalization is when we structure databases in a way that removes unnecessary dependencies such as partial/transitive, reduces data redundancy, and helps keep databases maintainable

pros: above
cons: can lead to many more tables than “required”

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

what is an ACID database?

A

Atomic, if you make a commit and it fails, all parts of it fail together and we do not get partial queries
Consistent, if you read the same data with the same query, you get the same result
Isolation, guarantees all transactions occur in isolation, transaction1 cannot affect transaction2. This means if t1 is a write, t2 cannot complete until t1 is finished writing so we do not get a dirty read
Durable, once commits are made, they remain in the system even in the event of a system crash following the transaction. If we succeed in a transaction, it must actually succeed

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

Dirty read, non-repeatable read, phantom read

https://stackoverflow.com/questions/11043712/what-is-the-difference-between-non-repeatable-read-and-phantom-read

A

dirty read, is when a transaction writes and a transaction reads, but the read complete before the write, so the read returns bad data
non-repeatable read, during a query, if a row is retrieved twice, the row returns different data each time
phantom read, with 2 identical queries, the rows are different between each query

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

Isolation levels

A

https://www.youtube.com/watch?v=-gxyut1VLcs

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

What are constraints in a database

A

??

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

What are constraints in a database

A

??

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