Unit 7 Relational databases and SQL Flashcards

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

When are databases used?

A
  • Databases are used in many business situations
  • They are also used at the back-end of many cloud services
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain some places where databases are used

A

School use:
- learning platforms such as Google Classroom
- management information systems such as SIMS or iSAMS

Organisation and business use:
- customer relationship management (CRM) software
- online calendars such as Google calendar
- the backend of most website to dynamically generated pages

Personal use:
- social media data
- multiplayer games

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

What is a database?

A
  • A database is a structured way to store data so that it can be retrieved using queries
  • Contains one or more tables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Data types

A

Just as when programming variables, database fields need to have a data type. The possible database data types to choose from are:
- Integer (whole number)
- Real, float, decimal (number with a decimal component)
- Data, Time, Datetime (to store dates and times)
- Char (fixed length string up to 8,000 characters)
- Varchar (variable length string up to 8,000 characters)
- Text (variable length string up to 2 GB of data)

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

Flat file databases

A
  • A flat file database stores a single table of data inside a single text file
  • Flat file databases are often stored using a CSV (comma separated values) format
  • Each record appears on a separate line, each field is separated by a comma
  • This format is very easy to set up, however, it is hard to manage for anything but the simplest of data sets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a primary key?

A

A field that stores unique data for each record in a table

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

Relational databases

A
  • A relational database contains multiple tables that are linked together using relationships
  • Relational databases allow us to design tables that reduce inconsistencies and eliminate data redundancy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is data redundancy?

A

When there is unnecessary data repetition in a database

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

What is a foreign key?

A

A field in a table that references the primary key of another table

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

What are the three possible relationship between tables in a database?

A

Relationships between tables can be:
- one-to-one
- many-to-many
- one-to-many

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
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
12
Q

What is SQL?

A
  • A language which allows you to create, query, update and delete data to and from databases
  • SQL is used with most Database Management Systems, including MySQL, SQL Server and MS Access
  • SQL queries can be used within high level programming languages such as Python
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Writing a query using SQL

A

The SQL syntax for querying a database is:
SELECT… list the fields to be displayed
FROM… specify the table name
WHERE… list the search criteria

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

What are the benefits of using relational databases?

A

They eliminate data redundancy and inconsistency

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

What are the benefits of using relational databases?

A

They eliminate data redundancy and inconsistency

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

What is SQL?

A

A language used for querying and updating database tables in a relational database

17
Q

When is the SELECT statement used?

A

To extract a collection of fields from one or more tables in a database

18
Q

What is the syntax of the SELECT statement?

A

SELECT list of fields to be displayed
FROM list the table or tables where the data will come from
WHERE list of search criteria

19
Q

ORDER BY

A

list the fields that the results are to be sorted on (either ASC or DESC)

20
Q

What is the default setting for ORDER BY?

A

Ascending

21
Q

What does the INSERT INTO statement do?

A

Used to insert a new record into a database table

22
Q

What is the syntax for the INSERT INTO statement?

A

INSERT INTO tableName (column1, column2,…)
VALUES (value1, value2,…)

23
Q

What does the DELETE statement do?

A

Used to delete a record from a database table

24
Q

What is the syntax for the DELETE statement?

A

DELETE FROM tableName
WHERE column = value

25
Q

What does the UPDATE statement do?

A

Used to amend a record in a database table

26
Q

What is the syntax for the UPDATE statement?

A

UPDATE tableName
SET column1 = value1, column2 = value2, …
WHERE column = value

27
Q

What problems can data redundancy cause?

A
  • An unnecessary amount of data storage capacity required to store the duplicated data
  • An increased risk of having inaccurate data
  • It is more time consuming and problematic to update the database