4.10 Fundamentals of Databases Flashcards

1
Q

Primary Keys (Definition)

A

A primary key is the unique identifier for each row.

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

Simple Primary Keys

A

Contain only one field to make a unique value

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

Composite Primary Keys

A

Contains more than one field to make a unique value

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

Foreign Keys

A

A field in one table that is linked to the primary key in another table

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

Entity

A

Table

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

Record

A

Row

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

Attribute

A

Field

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

Entity Definition

A

TableName (Primary Key, field1, field2)

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

Relationships: One to One

A

x -|——|- y

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

Relationships: One to Many

A

x -|——-<- y

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

Relationships: Many to Many

A

x -|——<- xy ->——| y

middle box contains foreign keys of other boxes to make primary key

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

Relationship Diagrams are called …

A

Entity-Relationship Diagrams (ERDs)

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

Normalisation Rules help …
(3)

A
  • organise data efficiently
  • eliminate redundant data
  • ensure only related data stored in table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

First Normal Form (4)

A
  • no columns with repeated or similar data
  • each data item cannot be broken down any further (atomic)
  • each row is unique (it has a primary key)
  • each field has a unique name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Second Normal Form (2)

A
  • must already be in 1NF
  • non-key attributes must depend on every part of the primary key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Third Normal Form (2)

A
  • must already be in 2NF
  • there are no non-key attributes that depend on another non-key attribute
17
Q

Benefits of Normalisation (5)

A
  • no redundant data = smaller database size = less £ on storage
  • less search data = faster query
  • no duplication = better integrity, less mistake risk
  • no duplication = less chance of storing 2+ different copies of data
  • instant change cascade
18
Q

Problems of Normalisation (5)

A
  • be careful with splitting data (atomic)
  • more tables
  • more tables/more complex = slower queries
  • more tables = must assign more relationships
  • more tables = more complex queries
19
Q

Insert: every field

A

INSERT INTO table VALUES (value1, value2);

20
Q

Insert: selected fields

A

INSERT INTO table (field1, field2) VALUES (value1);

21
Q

Update

A

UPDATE table SET fieldtochange = newfieldvalue WHERE condition;

22
Q

Delete

A

DELETE FROM table WHERE condition;

23
Q

Select

A

SELECT *
FROM table
WHERE condition;

24
Q

Select - Order By

A

ORDER BY Asc/Dsc

25
Q

Select - 2 Tables

A

SELECT *
FROM table1, table2
WHERE table1.PrimaryKey = table2.ForeignKey AND condition;

26
Q

DDL - Database Definition Language

A

CREATE TABLE tableName (
Id integer NOT NULL PRIMARY KEY,
field1 varchar(50),
field2 date/time);

27
Q

Different Data Types (6)

A
  • VARCHAR (x)
  • INT/INTEGER
  • FLOAT
  • REAL
  • BOOL
  • DATE/TIME