Quiz 3 Flashcards

1
Q

What is the purpose of indexing?

A

Speeds up data retrieval by avoiding full table scans.

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

What is a primary index?

A

Built on primary key; one entry per record; sorted.

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

What is a secondary index?

A

Built on non-primary key; may point to multiple records.

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

Define a dense index.

A

Every key value has an index entry.

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

Define a sparse index.

A

One index entry per block; fewer entries, more efficient for storage.

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

What is a multi-level index?

A

Index built over an index for scalability.

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

What is hashing?

A

Converts key to hash for fast lookup. Static or dynamic.

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

What are B+-Trees used for?

A

Balanced tree used for indexing; great for range queries.

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

How do you insert into B+-Trees?

A

Insert → Split if needed → Push middle key up.

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

What is a clustered index?

A

Physical data order matches index order; only one per table.

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

What is an unclustered index?

A

Logical ordering via pointers; table data unordered.

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

What is the SQL command for creating an index?

A

CREATE INDEX idx_name ON table(col);

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

What are best practices for indexing?

A

Index frequently queried columns, avoid over-indexing.

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

What is relational algebra (RA)?

A

Abstract way to write queries: σ (select), π (project), ⋈ (join).

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

What does logical plan equivalence refer to?

A

Two RAs are equivalent if same output for all valid inputs.

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

What are examples of equivalence in RA?

A

Selection pushdown, join associativity, commutativity.

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

What is cardinality estimation?

A

Predicting the number of rows a query step will return.

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

What is direct client access?

A

App directly connects to DB (less secure).

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

What is server access?

A

App uses a middle layer (more secure, scalable).

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

What does the CIA model stand for?

A

Confidentiality, Integrity, Availability.

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

What is authentication?

A

Verifying user identity.

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

What is authorization?

A

Verifying permissions.

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

What is role-based access control?

A

Permissions assigned to roles, roles assigned to users.

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

What is discretionary access control?

A

Data owner assigns access directly.

25
What is the SQL command to grant permissions?
GRANT SELECT ON table TO user;
26
What is the SQL command to revoke permissions?
REVOKE SELECT FROM user;
27
What is application-level security?
Input validation, prevent SQL injection.
28
What is SQL injection?
Code injection via unvalidated inputs. Use prepared statements.
29
What does ACID stand for?
Atomicity, Consistency, Isolation, Durability.
30
What is a lost update?
Overwriting another transaction’s changes.
31
What is a dirty read?
Reading uncommitted data.
32
What is an unrepeatable read?
Re-reading same data gives different results.
33
What are the states of a transaction?
Active → Partially Committed → Committed / Aborted.
34
What does scheduling determine?
Determines transaction execution order.
35
What is a serial schedule?
Transactions run one after another (safe but slow).
36
What is a serializable schedule?
Interleaved but equivalent to some serial order.
37
What is conflict-serializability?
If no cycles in precedence graph → serializable.
38
What is PostgreSQL MVCC?
Multi-Version Concurrency Control avoids locking.
39
What does read committed mean?
Sees only committed rows; may see different versions.
40
What does the serializable level prevent?
Prevents anomalies; forces serializable behavior.
41
What is a distributed database?
Single logical DB spread across nodes.
42
What is the difference between homogeneous and heterogeneous databases?
Same vs. different DB systems.
43
What is the difference between synchronous and asynchronous replication?
Immediate vs delayed replication.
44
What is partitioning in databases?
Splitting data: Horizontal (rows) vs Vertical (columns).
45
What is replication?
Copies data across nodes for fault tolerance.
46
What is the difference between ACID and BASE?
BASE is more relaxed: eventual consistency.
47
What does the CAP theorem state?
Consistency, Availability, Partition Tolerance — pick 2.
48
What is the difference between SQL and NoSQL?
SQL: structured, ACID. NoSQL: flexible, BASE.
49
What is denormalization?
Fewer joins, more redundancy. Better for read performance.
50
What is the structure of MongoDB?
Databases → Collections → Documents → Fields.
51
What is the command to insert a single document in MongoDB?
insertOne().
52
What is the command to insert multiple documents in MongoDB?
insertMany().
53
What is the command to read documents in MongoDB?
find(), projections select specific fields.
54
What is the command to delete a single document in MongoDB?
deleteOne().
55
What is the command to delete multiple documents in MongoDB?
deleteMany().
56
What is the command to update a single document in MongoDB?
updateOne(), updateMany() + $set.
57
What is static Hashing?
open hashing (separate chaining) and closed hashing (open addressing)
58
What is dynamic hashing?
offers a way for the hash table to adapt its size as needed.
59
What is password hashing?
a cryptographic process that transforms a user's plain text password into a seemingly random, fixed-length string of characters called a hash