Databases + SQL Flashcards

(32 cards)

1
Q

What is a database?

A

They are structured, persistent collections of data that can be easily accessed, searched, updated and managed.

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

What is a relational database?

A

A database that stores data in tables which are linked together using keys.

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

What is a table?

A

A structure that stores data in rows and columns.

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

What is a record?

A

A single row in a table that stores data about one item/person.

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

What is a field?

A

A single column in a table that stores one type of data.

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

What is a data type?

A

The type of data a field can store (e.g. integer, text, date, boolean).

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

What is a primary key?

A

A field that uniquely identifies each record in a table.

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

What rules must a primary key follow?

A

It must be unique and not empty.

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

What is a foreign key?

A

A field that links one table to another by referencing a primary key in another table.

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

What is data redundancy?

A

When the same data is stored multiple times unnecessarily

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

What is data inconsistency?

A

When the same data has different values in different places.

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

How do relational databases reduce redundancy and inconsistency?

A

By storing data once and linking tables using primary and foreign keys.

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

What does SELECT do?

A

Retrieves (gets) data from a database.

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

What does FROM do

A

Specifies which table the data is taken from.

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

WHERE

A

Filters records so only rows that meet a condition are shown or affected

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

What does ORDER BY do?

A

Sorts the results into a specific order.

17
Q

: What does ASC mean?

A

Sort in ascending order (small → big, A → Z).

18
Q

What does DESC mean?

A

Sort in descending order (big → small, Z → A).

19
Q

What does SELECT * do?

A

Selects all columns from a table.

20
Q

Write the basic structure of a SELECT query.

A

SELECT columns
FROM table
WHERE condition
ORDER BY column ASC|DESC;

21
Q

What does INSERT INTO do?

A

Adds a new record (row) to a table.

22
Q

Write the basic structure of INSERT.

A

INSERT INTO table (columns)
VALUES (values);

23
Q

What does UPDATE do?

A

Changes existing data in a table.

24
Q

Write the basic structure of UPDATE.

A

UPDATE table
SET column = value
WHERE condition;

25
Why is WHERE important in UPDATE?
Without it, every record in the table will be updated.
26
What does DELETE do?
Removes records (rows) from a table.
27
Write the basic structure of DELETE.
DELETE FROM table WHERE condition;
28
Why is WHERE important in DELETE?
Without it, all records in the table will be deleted.
29
Should text values be in quotes in SQL?
✅ Yes.
30
Should numbers be in quotes in SQL?
❌ No.
31
When using two tables, what must the WHERE clause usually include
A condition that links the primary key to the foreign key.
32
Advantages of databases
• Makes processing more efficient. • Reduces storage requirements. • Avoids redundancy.