7 - Databases Flashcards

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

What is a database? What is the difference between a (flat file) database and a relational database?

A

-permanent structured collections of data

-a flat file database has only one table, while a relational database has 2 or more tables that are related by foreign keys

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

What is a table in a database?

A

all of the data about a defined group of things structured with fields (columns) and records (rows)

a database can contain more than one table (that is a relational database)

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

Define a record:

A

all of the data about one particular object (as a row) in a table

both begin with r

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

Define a field:

A

a category within a table (as a column)

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

What are primary keys? Give some examples:

A

a unique identifier for each record in a table (e.g. a car number plate, website name, emails)

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

Define a foreign key:

A

the primary key from another table used to create a relationship between them

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

Name 4 ways in which tables in a relational database can be linked:

A

1:1
many:many
1:many
many:1

The example below is a 1:many

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

Why might you want to use a relational database?

A

reduces data inconsistency (data is different in different places) and redundancy (repeated data)

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

What does SQL stand for?

A

Structured Query Language

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

What is the select...from... command used for?

A

specifies the field(s) from the specified table(s) to be included in the displayed output table

The "FROM" part doesn't have to be on a separate line
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the where command used for?

A

specifies certain conditions that need to be met to filter the displayed output data

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

How do you put 2 where conditions after one another?

A
where [condition 1]
and [condition 2]
...
and [condition n]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you make a link between 2 tables in a relational database?

A
where table1.primaryKey = table2.foreignKey

primaryKey and foreignKey should be the same word/phrase in the two tables

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

How do you order data in SQL?

A

STOP FORGETTING THE FIELD NAME

order by [field name] asc/desc
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the insert command do? Give an example:

A

-inserts a new record into a table

insert into [table name] (field1, field2...)
values (value1, value2...)

You don’t have to give a specific field

In field 1, the new record will contain value 1

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

How could you change a certain record’s data in a specific field? Give an example:

A

-update command

update [table name]
set field1 = value1, field2 = value2...
where [condition]
17
Q

How can you delete records from a table that meet a certain condition?

A
delete from [table name] where [condition]