1.3.2 d + e – Databases - DONE Flashcards

(11 cards)

1
Q

How do you select data in SQL?

A

Using
SELECT field FROM table WHERE condition

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

How do you use SQL to find an item that starts with, ends with, or contains a specific character

A

[WHERE condition] becomes:

WHERE condition LIKE character% when searching for items that start with the character
WHERE condition LIKE %character when searching for items that end with with the character
WHERE condition LIKE %character% when searching for items that contain the character

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

How do you select the items in all fields of a record?

A

Using SELECT *

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

How do you implement multiple conditions?

A

Using AND and/or OR

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

How do you add a record into a database using SQL?

A

By inserting the record’s data using:

INSERT INTO table (field1, field2, field3)
VALUES(value1, value2, value3)

E.g. INSERT INTO world(name, capital, population)
VALUES(“Oz”, “Emerald City”, 1000000)

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

How do you delete a record/records from a table?

A

Using:
DELETE FROM table
WHERE condition

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

How do you join tables?

A

Using:
SELECT table.field
FROM table
JOIN table2,
ON table1.field = table2.field
WHERE condition

The specified field is the foreign key.

E.g.
SELECT Student.Surname, Tutor_Group.Tutor room
FROM Student
JOIN Tutor_Group
ON Student.Tutor Group = Tutor_Group.Tutor Group
WHERE Student.Tutor Group = “10B”

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

How do you delete a table?

A

Using:
DROP TABLE table

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

Describe referential integrity

A

When relationships between databases are consistent, such that each foreign key links to an existing primary key.

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

Why is referential integrity desirable?

A

It ensures that information is not removed if it is required elsewhere in a linked database, in order to prevent the occurrence of missing data.

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

How can referential integrity be broken?

A

If a primary key is deleted or updated or if a foreign key is no longer valid.

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