4.10 Fundamentals of Databases Flashcards

1
Q

Primary Keys (definition)

A

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 (definition)

A

Primary keys that only contain 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 (definition)

A

Primary key that 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 (definition)

A

A field in one table that is linked to the primary key in another table
A primary key that has come from 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 (4x2)

A
  • Easier to query data
    • no repetition of data
    • no redundant data
  • Less chance of errors
    • only one instance of each piece of data (no data duplication)
    • changes are cascaded throughout the database (only need to change the data once)
  • Queries run faster
    • less data to search through
    • database is optimised
  • Less money on storage
    • less data = smaller database size
18
Q

Problems of Normalisation (5)

A
  • Possibility of larger databases and more tables
    • requires more storage
    • requires more relationships to be assigned between tables
    • queries could run slower
    • queries are more complex
  • Need to be careful making data atomic
19
Q

Concurrent Access (3)

A
  • when more than one user has access to a record at the same time
  • could lead to overwriting entries/changes
  • could lead to losing data
20
Q

Record Locks (2)

A
  • when a user starts to edit a record, a lock is set on the record
  • other users can’t edit/access the record until the lock is released
21
Q

Timestamp Ordering (3)

A
  • timestamps generated for each transaction
  • timestamps indicate the order that transactions occurred in
  • timestamps can be generated for edits, queries and reading & writing of data
22
Q

Serialisation (2)

A
  • rather than locking, requests from other users are placed in a queue
  • once the first user has finished using the field, the next command in the queue is executed
23
Q

Commitment Ordering (3)

A
  • an algorithm is used to work out an optimum order in which to execute commands for the same field
  • algorithm takes into account the impact of command on other parts of the database
  • algorithm attempts to minimise issues from occurring
24
Q

Insert: every field

A

INSERT INTO table VALUES (value1, value2);

25
Insert: selected fields
INSERT INTO table (field1, field2) VALUES (value1);
26
Update
UPDATE table SET fieldtochange = newfieldvalue WHERE condition;
27
Delete
DELETE FROM table WHERE condition;
28
Select
SELECT * FROM table WHERE condition;
29
Select - Order By
ORDER BY Asc/Dsc
30
Select - 2 Tables
SELECT * FROM table1, table2 WHERE table1.PrimaryKey = table2.ForeignKey AND condition;
31
DDL - Database Definition Language
CREATE TABLE tableName ( Id integer NOT NULL PRIMARY KEY, field1 varchar(50), field2 date/time);
32
Different Data Types (6)
- VARCHAR (x) - INT/INTEGER - FLOAT - REAL - BOOL - DATE/TIME
33
Normalisation (definition)
Process of storing data while removing redundant data and elimination data duplication
34
Client Server Databases (3)
- Provides simultaneous access to the database for multiple clients - Idea: client requests data from server by a connection made over WAN/LAN - Once request fulfilled, connection terminated
35
Advantages of Client Server Databases (5)
- data stored in single location - data accessed any time/where (with permission) - database can grow without client needing to improve - centralised back ups - increased security as what client can perform/access is restricted
36
Disadvantages of Client Server Databases (5)
- database can become overloaded with data leading to slow response - data corruption - concurrent access - servers & hardware not cheap to implement/maintain - specialists required to maintain
37
CRUD Acronym
Create --> Insert Retrieve --> Select Update --> Update Delete --> Delete
38
REST - acronym - function - mapping
- Representational State Transfer - Mapping Javascript (database) --> HTML - GET --> SELECT - POST --> INSERT - DELETE --> DELETE - PUT --> UPDATE`
39
JSON vs XML (4)
- easier for humans to read/understand - more compact representation - easier to create and code - easier for computers to parse therefore quicker to parse