SQL And Databases Flashcards

1
Q

What is a database?

A

A database is an organised collection of data that can be easily accessed, managed, and updated.

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

What is a record in a database?

A

A record is a single row in a table that contains data about one item.

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

What is a field in a database?

A

A field is a column in a table that holds one piece of data about every record.

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

What is a primary key?

A

A primary key is a field that uniquely identifies each record in a table. It cannot be duplicated or left empty.

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 field in one table that links to the primary key in another table, creating a relationship between the tables.

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

What is a flat file database?

A

A database that stores all data in a single table. It is simple but can lead to data redundancy.

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

What is a relational database?

A

A database that stores data in multiple related tables, reducing redundancy and improving data integrity.

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

What is SQL?

A

SQL (Structured Query Language) is the standard language used to create, modify, and query databases.

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

What does the SQL SELECT statement do?

A

It retrieves data from a database.

Example: SELECT name FROM students returns the name field from the students table.

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

What does the SQL WHERE clause do?

A

It filters results based on a condition.

Example: SELECT * FROM students WHERE grade = ‘A’ returns only students with grade A.

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

What does * mean in an SQL query?

A

It means “select all fields”.

Example: SELECT * FROM students returns every column from the students table.

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

How do you sort results in SQL?

A

Use ORDER BY.

Example: SELECT name FROM students ORDER BY age sorts by age.

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

How do you rename a field in the output using SQL?

A

Use AS.

Example: SELECT name AS student_name FROM students.

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

What does the SQL INSERT INTO command do?

A

It adds new data to a table.

Example: INSERT INTO students (name, grade) VALUES (‘Alice’, ‘A’).

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

What does the SQL UPDATE command do?

A

It changes existing data.

Example: UPDATE students SET grade = ‘B’ WHERE name = ‘Alice’.

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

What does the SQL DELETE command do?

A

It removes data from a table.

Example: DELETE FROM students WHERE name = ‘Alice’.

17
Q

Why is validation important in databases?

A

Validation checks that data entered is sensible and reasonable, improving data integrity and reducing errors.