Chapter 6: Databases Flashcards

1
Q

Database

A

A structured collection of related data

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

A database is structured in a way that allows you to… (3)

A
  1. Search (find data)
  2. Sort (order the data)
  3. Add, update and remove (change the data)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Popular ways of sorting data include… (3)

A
  1. Alphabetical OR reverse alphabetical
  2. Numerical OR reverse numerical
  3. Chronological OR reverse chronological
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the two main types of databases?

A
  1. Flat-file

2. Relational

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

Flat-file database

A

Stores all of its data in a single table

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

Pros and Cons of a Flat-file database (3 | 3)

A

Pros

  1. Simple and easy to implement
  2. Easy to access using many different applications
  3. Easy to understand - all information stored in one place

Cons

  1. Easy to extract information - less secure
  2. Data duplication makes data inconsistency more likely
  3. Searching process is time-consuming with larger databases
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Relational database

A

Organises its data into related tables of records

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

Pros and Cons of a Relational database (4 | 2)

A

Pros

  1. Information only has to be written or updated in one area - less data duplication
  2. More efficient storage
  3. Flexible and well-established
  4. Standard data access language in SQL

Cons

  1. Harder to design and maintain
  2. Has a lot of overhead and complexity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Data duplication OR Data redundancy

A

Where the same data is stored more than once, unnecessarily

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

Data duplication leads to…

A

Data inconsistency

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

Data inconsistency

A

Where different and conflicting versions of the same data appear in different places, thus compromising data integrity

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

Entity

A

A single person, place or thing about which data can be stored

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

Table

A

A collection of data about a certain topic organised into records and fields

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

Record

A

Data stored about a particular entity within a table

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

Field

A

One specific data item being stored about a particular entity

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

Fill in the blanks:

Records form the _____ of a table. Fields form the table’s _____.

A
  1. Rows

2. Columns

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

Primary key

A

The field in a table that uniquely identifies a record

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

How many times can a primary key occur in a table?

A

Once

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

Foreign key

A

A field in one table that is the primary key in another, used to create a relationship between the two

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

Relationship

A

A connection between two tables

21
Q

How do you form a relationship?

A

By including the primary key of one table as a foreign key in another

22
Q

What are the three different kinds of relationships between tables?

A
  1. One-to-one
  2. One-to-many OR many-to-one
  3. Many-to-many
23
Q

Index

A

A data structure defined along the columns of a database table, used to significantly speed up queries

24
Q

How does an Index work?

A

It sorts the data by the most commonly searched columns

25
Q

Pros and Cons of using an Index (4 | 2)

A

Pros

  1. Usually leads to much better performance
  2. Makes it possible to quickly retrieve data
  3. Can be used for sorting
  4. Unique indexes guarantee uniquely identifiable records in the database

Cons

  1. They decrease performance on inserts, updates and deletes
  2. They take up disk space
26
Q

Primary index

A

The primary key field

27
Q

SQL

A

Structured Query Language: a high level command language, used to search through and manipulate databases

28
Q

Query

A

A request for information from a database based on specified criteria

29
Q

Format of a Query that selects data from one or more Tables based on a certain condition in a specified order of one or more fields

A

SELECT [field(s)]
FROM [Table(s)]
WHERE [condition(s)]
ORDER BY [field(s)] [optional order keyword]

30
Q

SELECT [field(s)]

A

Lists the Fields you want to display

31
Q

FROM [Table(s)]

A

Lists the Table or Tables where the data will come from

32
Q

WHERE [condition(s)]

A

Lists the search criteria

33
Q

Logical operator

A

NOT, AND or OR. Used in complex criteria in queries

34
Q

ORDER BY [field(s)] [optional order keyword]

A

Lists the Field or Fields by which the data is sorted in a certain order

35
Q

What two keywords can be used with the ORDER BY clause?

A
  1. ASC: ascending

2. DESC: descending

36
Q

What is the default order using ORDER BY?

A

Ascending, although the ASC may still be included for clarity

37
Q

Format of a Query that inserts a Record into a Table (column names not specified)

A

INSERT INTO Table

VALUES ([values])

38
Q

Format of a Query that inserts a Record into a Table (column names specified)

A

INSERT INTO Table ([columns])

VALUES ([respective values])

39
Q

Do all of the Fields within a Record have to be filled?

A

No. Any unfilled Fields will have the NULL value

40
Q

Format of a Query that changes the value of a Field when certain criteria is met

A

UPDATE Table
SET field = value
WHERE [condition(s)]

41
Q

Format of a Query that deletes one or several Fields from a Record

A

DELETE [field(s)]
FROM Table
WHERE Primary_key = value

42
Q

Format of a Query that deletes a Record

A

DELETE *
FROM Table
WHERE Primary_key = value

43
Q

Format of a Query to delete a Table

A

DROP TABLE Table

44
Q

Why should you be careful when using DELETE and DROP TABLE statements?

A

SQL doesn’t warn you before executing commands, so you could accidentally delete important information

45
Q

Format of a Query to create a Table

A
CREATE TABLE Table
(
column data_type
[...]
)
46
Q

How do you show which Table a particular Field comes from when the Query involves more than one Table’s contents?

A

Dot notation

47
Q

How would you refer to the title attribute of the Books Table?

A

Books.title

48
Q

What does the * wildcard character mean?

A

All

49
Q

What does the following Query do?

SELECT id, title
FROM Movies
WHERE duration >= 86 AND genre = ‘Horror’
ORDER BY duration ASC;

A

Lists the ID and title of any horror movies with a duration of 86 minutes or longer from the Movies table, in ascending order of duration