unit 7 - relational databases and SQL Flashcards

1
Q

what are some examples of organisations that use databases?

A
  • schools - google classroom
  • businesses - google calendar
  • personal use - social media data, multiplayer games
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is a database?

A

a structured way to store data so that it can be retrieved using queries

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

what is a table?

A

it stores records and fields in an organized manner

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

what is a record?

A

an individual collection of data for one person/object, a row in a table

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

what is a field?

A

one item of data, a column in a table

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

what is the date, time variable used for?

A

to store dates and times eg. DOB (date), time a message was sent (datetime)

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

what is a varchar?

A
  • variable length string (can contain letters, numbers, and special characters)
  • up to 8000 characters) eg. first name or telephone number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is a flat-file database?

A

stores a single table of data inside a single text file
- often stored using a CSV (comma separated values) format
- each record appears on a separate line
- each field is separated by a comma

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

what are the advanatges and disadvantages of flatfile databases?

A

+ easy to set up

  • 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
10
Q

what are some issues with flatfile databases and how can these be solved?

A

data often has to be repeated, leading to:
- inconsistencies in the data - makes it hard to search or sort the data
- causes redundant data - the databases use more memory or storage than it needs to + it may take longer to search

can be solved by using relational databases

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

what is a primary key?

A

a field that stores unique data for each record in a table
- first names, last names and DOBs are not unique
- a mobile number (varchar) is unique so can used as a primary key, or an ID number (int or auto-number)

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

what is a relational database? and what are the advnatges of these?

A
  • contains multiple tables and each table has links known as relationships
  • each table is known as a relation

+ allows 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
13
Q

what is a foreign key?

A

a field in a table that references the primary key of another table
- each table has a primary key which is used to uniquely identify each record
- a second table can refer to the info in the first table by referring to its primary key but in this case it is referred to as a foreign key

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

what are the three different relationship types in databases?

A
  • one-to-one
  • many-to-many
  • one-to-many
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is SQL?

A

structured query language - a language that allows you to create, query, update and delete data to and from databases
- used in DBMS

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

what does the SELECT statement do?

A

list the fields for the data to be displayed

17
Q

what does the FROM statement do?

A

specify the table name that you are querying

18
Q

what does the WHERE statement do

A

list the search criteria - like conditions for what you’re querying for
- operators =, ≠, >,<, ≥, ≤, AND, OR, NOT can be used in this statement

19
Q

how do you select all the fields of a table?

A

SELECT *

FROM members

20
Q

what does the BETWEEN statement do?

A

conditional like the WHERE statement but gives a range instead

21
Q

what does the LIKE statement do?

A

searches for a pattern
eg. SELECT * FROM members WHERE surname LIKE ‘H*’

22
Q

how do you update records?

A
  • data stored in records can be changed + more than one record can be changed at a time
  • UPDATE statement -> UPDATE Dogs SET Age = 4 WHERE Age = 3
23
Q

how do delete records?

A
  • the WHERE criteria allows more than one record to be deleted at a time
  • if using tables with relationships that these aren’t affected by deletion
  • use the DELETE FROM …. WHERE eg. DELETE FROM Dogs WHERE Breed = ‘Labrador’ AND Colour = ‘Brown’
24
Q

how do you join two tables?

A

a query can be made where info is selected from two tables