3.7 Databases And SQL Flashcards

1
Q

Tables

A

Where data is stored.

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

Records

A

A single entity within a table.

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

Field

A

A single item of information within a table.

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

Primary key

A

A field (or combination of fields) that uniquely identify a record.

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

Foreign key

A

A field that links a record in one table to a record in another table.

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

Database

A

A method of storing information.
• Flat file
• Relational

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

Flat file

A

Data is stored simply in one table.
• Easier to setup
• Harder to manage
• Takes up more space
• Data repetition - redundancy : can lead to inconsistency, mistakes.

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

Relational

A

Data is stored in multiple tables that can be linked together.
• Requires expertise to setup
• When setup well can be easier to manage
• Optimised storage use
• Data should be stored just once, minimises redundancy : prevents inconsistency, reduces errors

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

Relational databases: Keys

A

Data is stored in tables which have Relations.
We link information across tables using keys.
• Primary keys
• Foreign keys

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

Primary Key

A

A field which is unique for each record within a table.

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

Foreign Key

A

A field which is the Primary Key with another table, enabling us to link it.

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

How do we show relations?

A

Using Entity Relationship Diagrams.

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

SQL

A

Specialist computer language used for querying Relational Databases
Standard basic Syntax across all RDBMS systems
Allows us to manipulate with data in a database:
• Creating
• Change
• Adding
• Deleting
• Querying (Retrieving)

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

Retrieving data:
Select statement

A

Four parts:
1. SELECT – What information do we want?
2. FROM – Which table(s) hold the information?
3. WHERE – Are there any criteria we need to match?
4. ORDER BY – How the data should be sorted/organised

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

Insert statement

A

We use SQL to insert information into our Database.
It has the following structure:

  1. INSERT INTO – The table (and fields) we are adding 2. VALUES – The data we are adding
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Delete statement

A

We use SQL to remove information from our Database.

It has the following structure:
1. DELETE FROM – The table we are deleting from
2. WHERE – The records we want to remove

BEWARE…NO UNDO UNLESS PLANNED FOR!!!! It can be wise to run your WHERE clause as a SELECT first to double check you are doing what you want to

17
Q

Editing/Updating data

A

The UPDATE Statement
We use SQL to update information in our Database.
It has the following structure:
1.UPDATE – The table we are updating
2.SET – The fields we are updating
3. WHERE – The record(s) we want to update

BEWARE…NO UNDO UNLESS PLANNED FOR!!!! It can be wise to run your WHERE clause as a SELECT first to double check you are doing what you want to