3.7 Relational Databases and SQL Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a database?

A

A database is a persistent collection of organised storage that can be retrieved through queries

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

What is SQL?

A

Structured Query Language

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

What is data redundancy?

A

Duplicate pieces of data

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

What is data inconsistency?

A

Storing repeated data in the same table can lead to inconsistencies in the data

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

Range check

A

A number or date is within a sensible/allowed range i.e. Month between 1 and 12

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

Type check

A

Data is the right type

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

Length check

A

Text entered is not too long or too short - for example a password is between 8 and 15 characters

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

Presence check

A

Checks that the data has been entered, i.e. The field has been left blank

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

Format check

A

Checks the format is correct, for example, a postcode or email is correct

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

List check

A

Making sure the user enters the right thing from a list. They can only select an option from a drop-down menu.

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

What wildcard is used to represent everything?

A

*

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

SQL SELECT

A

Select *
FROM table1

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

SQL WHERE

A

Select *
FROM table1
WHERE Forename = ‘Bob’

  • If the value is a string (or varchar, text etc.) then it requires quotation marks.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

SQL SELECT SORTING

A

Select Forename, Surname
FROM table1
ORDER BY Surname ASC

  • ASC = Ascending
  • DESC = Descending
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

SQL INSERT

A

INSERT INTO table1 (userId, Forename, Surname, Age, Height, MobileNumber)
VALUES (1, ‘Bob’, ‘Jones’, 47, 1.87, ‘07834 577780’)

  • If the value is a string (or varchar, text etc.) then it requires quotation marks.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

SQL UPDATE

A

UPDATE table1
Surname = ‘Rich’
WHERE userId = 1

It is the safest option to use the primary key as if you use another field, then you might change someone else’s details as well.

17
Q

SQL DELETE

A

DELETE FROM table1
WHERE userId = 1

18
Q

SQL Joining two tables

A

SELECT table1.Forename, table1.Surname, table2.Address
FROM table1
INNER JOIN ON table1.userId = table2.userId
WHERE userId = 1

19
Q

Primary key

A

A primary key is a field in a database table and acts as a unique identifier for each record.

20
Q

Foreign key

A

It is the reference to the primary key of another table.
It is used to create a link/relationship between two tables.

21
Q

What is an integer?

A

A whole number

22
Q

What is a float?

A

A number with a fractional component (a decimal)

23
Q

What is datetime

A

Date and Time

24
Q

What is a char?
In databases

A

A string of fixed length (up to 8,000 characters long)

25
Q

What is a varchar?

A

A string of variable length (up to 8,000 characters long)

26
Q

What is text?

A

A string of variable length (up to 2GB of data)