Fundamentals of Databases Flashcards

1
Q

What is a field?

A

A column in a database

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

What is a record?

A

A row in a database

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

What is a primary key?

A

A unique field in a database table which indexes a record

Identified by an underline

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

What are the three entity-relationships?

A

One-to-one

Many-to-many

One-to-many

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

What is a foreign key?

A

A foreign key is a column in a database table that links to the primary key of another table, establishing a connection between the two tables.

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

Why are databases normalised?

A

Database normalization is done to reduce data redundancy and improve data integrity, ensuring consistency and efficient use of storage.

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

What is First Normal Form?

A

Contains only atomic values; each column has only one value.

A column should only contain values of the same type.

Each row holds a unique set of data; doesn’t have repeating field names.

It doesn’t matter what order the data is in; we can fetch it from anywhere using a query.

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

What is Second Normal Form?

A

To be in second normal form, it must be in first normal form and not contain any partial dependency.

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

What is Partial Dependency?

A

When a primary key is made up of two columns, and an attribute depends on only one of these columns.

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

How do you remove Partial Dependency?

A

Move it to another table where it can be dependent on one key.

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

What is Third Normal Form?

A

Where there’s no transitive dependency and it’s in 2nd and 1st normal form.

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

What is Transitive Dependency?

A

A condition in which an attribute is dependent on another attribute that isn’t a part of the primary key.

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

How do you remove Transitive Dependency?

A

Split the fields which had the transitive dependency into new tables.

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

SELECT Command

A

Used to retrieve data from a database table

SELECT <column> FROM <table> WHERE <condition> ORDER BY <column><ASC/DESC></column></condition></column>

The ORDER BY is optional
- Defaults to ASC

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

UPDATE command

A

Used to modify the attributes of an existing entity

UPDATE <table> SET <column> = <value>
WHERE <column> = <value></value></column></value></column>

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

DELETE command

A

Used for removing entities from a database

DELETE FROM <table>
WHERE <condition></condition>

15
Q

INSERT command

A

Used to add new records to an existing table

INSERT INTO <table> VALUES (<value1>, <value2> …)</value2></value1>

INSERT INTO <table> (<column1>, <column2> ...) VALUES (<value1>, <value2> ...)</value2></value1></column2></column1>

16
Q

What is a Wildcard?

A

Used in SQL to specify ALL.

Signified by a * symbol

17
Q

How to create a table?

A

CREATE TABLE <table_name>
(<column-name> <column-type>,</column-type></column-name></table_name>

<column-name> <column-type>

PRIMARY KEY (<column-name>)
)

data types include..... VARCHAR, INT, SMALL MONEY etc
</column-name></column-type></column-name>

18
Q

What is a client-server database?

A

A client-server database is a system where one server machine hosts a database and multiple client machines access it over a network. The server manages, stores, and retrieves the data as requested by the clients.

19
Q

What is Concurrent Access?

A

This issue arises when multiple users try to access the same field at the same time, leading to potential loss of database updates. It can be managed using record locks, serialisation, timestamp ordering, and commitment ordering.

20
Q

What are Record Locks?

A

When a field is accessed by a user, it gets locked for other users until the first user is done. This prevents others from accessing or modifying the field until it’s unlocked.

21
Q

What is Serialisation?

A

Instead of locking a field, requests from other users are queued. After the first user is done, the next command in the queue is executed.

22
Q

What is Timestamp Ordering?

A

Each command sent to the same field in a database is assigned a timestamp. Commands are executed based on their timestamps.

23
Q

What is Commitment Ordering?

A

An algorithm is used to determine the optimal order to execute commands for the same field. This algorithm considers the impact of commands on other parts of the database to minimize potential issues.

24
Q

What is an INNER JOIN in SQL?

A

An INNER JOIN combines rows from two tables based on a related column between them. It’s like matching and merging information from two different lists based on a common key.

SELECT Orders.OrderID, Customers.CustomerName, Orders.Product
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;