Unit 7: Relational databases and SQL

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/35

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

36 Terms

1
New cards

How is data stored?

Large amounts of data are collected & organised in a data base.

2
New cards

What is a database?

A database is a structured set of data. It is structured in tables that are easy to search and update.

3
New cards

What are records?

A collection of data for 1 object, person or thing

4
New cards

What are fields?

To provide category headings for each piece of data in the database.

5
New cards

What are tables?

Holds a collection of records for a particular themes

6
New cards

Database data types

Integer, real/float/decimal, date/time/datetime, char, varchar, text

7
New cards

Integer

Whole number.

ex = age

8
New cards

Real/Float/decimal

Number with decimal component.

ex = height

9
New cards

Date/time/datetime

to store data and times.

ex = message sent time

10
New cards

Char

fixed length string up to 8000 characters.

ex = telephone number

11
New cards

Varchar

Variable length string up to 8000 characters; values can change.

ex = telephone number

12
New cards

Text

Variable length string up to 2GB of data.

13
New cards

Flat file databases

- A flat-file database stores a single table of data inside a single text file.

14
New cards

Components of a flat-file database

- Stored using a CSV (comma separated values) format.

- Each record appears on a separate line.

- Each field is separated by a comma

15
New cards

Flat-file database issues:

- Leads to inconsistencies in data; hard to search/sort the data.

- Causes redundant data - so databases uses more memory or storage than it needs to, may take longer to search.

16
New cards

Redundancy:

Data redundancy created within a database when the same piece of data is held in several places.

Leads to records with duplicated data and data inconsistency.

17
New cards

Relational databases:

A relational database contains multiple tables. These tables will have links known as relationships. Each table is also known as an entity.

18
New cards

Relational databases allow us to....

- design tables that reduce inconsistencies and eliminate data redundancy.

19
New cards

Primary key:

A primary key can never be repeated. Ensures that each record in the table is unique; very important when dealing with thousands/millions of records.

20
New cards

Foreign key:

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

21
New cards

Relationships between tables (entities) =

- One to one

- many to many

- one to many

22
New cards

relationship; one to one

---------

23
New cards

Relationship; many to many

>-------<

24
New cards

Relationship; one to many

--------<

25
New cards

SQL:

Structure query language; used to communicate with a database. Can be used to manipulate databases and retrieve records.

26
New cards

SELECT

used to retrieve data from a database

27
New cards

FROM

the table

28
New cards

WHERE

the criteria has been met.

29
New cards

SELECT *

select all fields

30
New cards

Retrieving data from more than one table:

- you need to specify table that the field names belong to in the SELECT block = ex- tblMembers.Surname

- Need to list each table that you wish to retrieve data from in the FROM block. ex - tblMembers, tblDownloads

- Need to state how the tables are joined together. ex- WHERE tblMembers.MemberID = tblDownloads.MemberID.

31
New cards

Types of SQL commands

- SELECT

- FROM

- WHERE

- ORDER BY; ASC, DESC

- INSERT INTO; VALUES

- UPDATE; SET

- DELETE FROM

32
New cards

Boolean logic

AND, OR, NOT

33
New cards

ORDER BY

ASC = will go from A-Z or 1-10

DESC = Z-A or 10-1

34
New cards

INSERT INTO

Used to record new records in a table.

ex = INSERT INTO Table (Fields)

VALUES (values to put into fields)

35
New cards

UPDATE

Used to modify existing records in a table

ex = UPDATE Table

SET Fields = 'New value'

36
New cards

DELETE FROM

Used to delete existing records in a table

ex = DELETE FROM Table

WHERE Field = 'Deleted value'