Databases and Software Development Flashcards

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

Database

A

Organised collection of data that is structured in a way to facilitate efficient retrieval, updating and analysis of data

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

Data model

A

Describes data, its structure, its relationships and constraints for a given system

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

Factors to consider when modelling entity relationships

A
  • Data needed to be stored
  • What real-world entities this data relates to
  • Relationships between entities
  • Constraints on data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Entity

A

Object about which data is being stored

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

Entity representation in databases

A

As tables

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

Attribute

A

Property of an entity

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

Attribute representation in databases

A

As fields/columns

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

Instance

A

Details of a particular occurence of an entity

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

Instance representation in databases

A

As records/columns

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

Relationship types

A
  • One-to-one (e.g. a school has one headteacher; a headteacher only has one school)
  • One-to-many
  • Many-to-one
  • Many-to-many (resolved by creating two one-to-many relationships)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Relational database

A

Type of database where:
* Separate table created for each entity
* Where relationship exists, foreign key links two tables

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

Entity identifier

A

(Collection of) attributes that uniquely identifies each instance of an entity

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

Primary key

A

Practical implementation of entity identifier

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

Foreign key

A

Attribute that creates a join between two tables (is primary key of another table)

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

Entity descriptions

A

Entity(Primary key, Attribute2 …)

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

Entity relationship diagrams

A
  • Diagrammatic way of representing the relationships between the entities in a database
  • Crow’s feet = many side
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Problem with many-to-many relations

A

Storing multiple foreign keys per instance -> Unnormalised entity -> Inefficiency

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

Resolving many-to-many relations

A
  • Composite/link entity created
  • Each instance represents each relation by storing both foreign keys
  • Create two one-to-many relations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Composite primary key

A

Consists of more than one attribute

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

Relation

A

Entity that is linked to other entities

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

Tuple

A

Row within relation (represents instance)

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

Normalisation

A

Process of structuring data in a relational database to reduce redundancy, increase accuracy and increase efficiency

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

Key features of normalisation

A
  • No redundant data
  • Each relation represents a single concept
  • Data is stored at its atomic level (can’t be decomposed further)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Redundant data

A

Unnecessarily duplicated data

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

Why is redundant data bad?

A
  • Redundant data → Wasted space and slower searching → Inefficiency
  • Redundant data → ↑ Chance of incorrect copying → Inconsistent and inaccurate data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Atomic-level data

A

Data has been fully decomposed into multiple attributes

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

Levels of normal form

A
  1. First normal form (1NF)
  2. Second normal form (2NF)
  3. Third normal form (3NF)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

First normal form (1NF)

A

Data is fully atomic and doesn’t have multiple values for any attributes (repeating groups)

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

Second normal form (2NF)

A

Separates non-key attributes that don’t relate to whole primary key (partial dependencies) into their own relations (only occurs when primary key is composite)

30
Q

Third normal form (3NF)

A
  • All attributes are dependent on the key, the whole key and nothing but the key
  • Achieved by removing non-key attributes that depend on other non-key attributes from a relation via creating more relations
31
Q

Advantages of normalisation

A
  • Maintaining and modifying database
  • Faster sorting and searching
  • Deleting records
32
Q

Maintaining and modifying the database

A
  • Data integrity maintained (no unnecessary duplication of data) -> No possibility of inconsistencies
33
Q

Faster searching and sorting

A
  • Produces smaller tables with fewer fields -> Faster searching, sorting and indexing (less data involved)
  • Holding data once -> Saves storage space
34
Q

Deleting records

A
  • Won’t allow record on ‘one’ side of one-to-many relationship to be accidentally deleted
    *
35
Q

Structured Query Language (SQL)

A

Declarative language used for querying, updating and creating tables in a relational database

36
Q

SELECT statement

A

Returns data from listed fields where condition is met

37
Q

SELECT syntax

A
SELECT field1, field2, etc.
FROM table1, table2, etc.
WHERE condition
ORDER BY field1, field2, etc.
38
Q

SELECT from multiple tables

A
SELECT Song.SongTitle, Artist.ArtistName, Song.MusicType
FROM Song, Artist
WHERE (Song.ArtistID = Artist.ArtistID) AND (Song.MusicType = "Art Pop")

OR
~~~
SELECT Song.SongTitle, Artist.ArtistName, Song.MusicType
FROM Song
WHERE Song.MuscType = “Art Pop”
JOIN Artist ON Song.ArtistID = Artist.ArtistID
~~~

39
Q

Not equal to

A

<>

40
Q

IN

A

Equal to value within set of values

41
Q

LIKE

A

Equality when using wildcards

42
Q

BETWEEN x AND y

A

Equal to value within set of values defined by limits x and y

43
Q

IS NULL

A

Field doesn’t contain a value

44
Q

%

A
  • Represents zero or more characters
  • E.g. bl% finds black, blue, etc.
45
Q

_

A
  • Represents a single character
  • E.g. b_t finds bat, but, etc.
46
Q

[]

A
  • Represents any single character within brackets
  • b[au]t finds only bat and but
47
Q

[^]

A
  • Represents any character not in brackets
  • E.g. b[^au]t finds any combination except bat and but
48
Q

-

A
  • Represents any character within brackets specified by range
  • E.g. b[a-u]t finds any combination of letters from a to u
49
Q

Data types

A
  • CHAR(n) (fixed length string)
  • VARCHAR(n) (variable length string max size n)
  • DATE (stores day, month and year values)
  • TIME (stores hour, minute and second values)
  • CURRENCY (formats numbers into currency format of current region)
50
Q

CREATE TABLE syntax

A
CREATE TABLE Employee
(
EmpID INTEGER NOT NULL PRIMARY KEY,
EmpName VARCHAR(20) NOT NULL,
HireDate DATE,
Salary CURRENCY
)
51
Q

Defining linked tables

A
FOREIGN KEY CourseID REFERENCES Course(CourseID)
52
Q

Add field

A
ALTER TABLE Employee
ADD Department VARCHAR(10)
53
Q

Delete a field

A
ALTER TABLE Employee
DROP COLUMN HireDate
54
Q

Modify field

A
ALTER TABLE Employee
MODIFY COLUMN EmpName VARCHAR(30) NOT NULL
55
Q

UPDATE statement

A

Updates record in a table

56
Q

UPDATE syntax

A
UPDATE table
SET column1 = value1, column2 = value2, ...
WHERE columnX = value
57
Q

DELETE statement

A

Deletes a record from a table

58
Q

DELETE syntax

A
DELETE FROM table
WHERE columnX = value
59
Q

Aggregate functions

A

Used in conjunction with SELECT statement (replaces fields)

60
Q

Aggregate function examples

A
  • MIN(field)
  • MAX(field)
  • COUNT(field)
  • SUM(field)
61
Q

GROUP BY

A
  • Separates output values based on the record’s value in the given field
  • Displays aggregate function values clearer
62
Q

Client-server application model

A
  • Consists of central server (abstraction) and multiple clients connecting to it
  • Core data and services stored and provided server-side
  • Interaction with data via lighter, ‘simpler’ client-side applications
63
Q

Advantages of client-server model

A
  • Data stored in one place -> Consistency of database
  • Data easily shareable across multiple devices
  • Data, backup and recovery can be centrally managed
  • Central security management
64
Q

Disadvantages of client-server model

A
  • If server goes down, risk of data becoming lost or inaccessible
  • Multiple users accessing server simultaneously -> Congestion and poor performance
  • Requires conflict management
65
Q

Relational Database Management System (RDBMS)

A

Provides client-server support, including handling concurrent access

66
Q

Lost update problem

A

When two users attempt to update the same record simultaneously -> One update being lost or both being applied incorrectly

67
Q

Record locks

A
  • Lock applied to record when a transaction (read/write) on it is started
  • Prevents other users from reading from or writing to it
68
Q

Problem with record locks

A

Deadlock - where two users attempt to access the same record or access a pair of records such that they are both locked out

69
Q

Serialisation

A

Method of ordering transactions into a queue

70
Q

Timestamp ordering

A
  • Each transaction’s timestamp is recorded in DB
  • To prevent timestamps being lost, every object has read and write timestamps
  • T_w should be aborted if read/write timestamp on record is greater (more recent)
  • T_r should be aborted if write timestamp on record is greater
71
Q

Commitment

A

Process of writing changes to a database permanently

72
Q

Commitment ordering

A
  • Extends timestamp ordering
  • Concurrent transactions commited in particular order -> Avoids data update issues and risk of deadlock
  • Order of commits determined by interaction of commitments & dependencies on common data