Databases Flashcards

1
Q

What is a Database?

A

A database is an organised, persistent collection of data.
Organised: Data organised into tables, records and fields
Persistent: Non-volatile using secondary storage
Data: Raw info with no context

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

What does a database consist of?

A

Files, records and fields

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

What operations can be performed on databases?

A
  • Can be organised/sorted in numerous ways
  • Displayed/Printed in a variety of styles/layouts
  • Searched for info and updated
  • Backed up easily and automatically
  • Local or distributed
  • Stored/Moved easily
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an attribute?

A

An individual fact, detail or characteristic of an entity (aka a field)

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

What is an entity?

A

A thing, person, object or relationship about which data can be collected

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

What is a flat file database?

A

A database containing a single table

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

What is a primary key?

A

A unique piece of information within a table to identify a record

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

What is a foreign key?

A

A field in the table which contains the value of a primary key in another table (links to one record)

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

What is redundancy?

A

Duplication of data within a database

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

What is a record?

A

A collection of fields/attributes about the same thing, person, object or relationship in a table

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

What is a relational database?

A

A database with multiple linked tables

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

What is a conceptual data model

A

a representation of the data requirements constructed in a way that is independent of any software used to construct the database

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

Click to view a relationship example

A

e.g.
Entities:

Student, Teacher, Class, Subject, Classroom…

Attributes:

Student: first name, second name, DOB, student number, year group, form ▪ Teacher: first name, last name, Subject, Teacher ID, DOB
Subject: Subject ID, Requirements, Max Intake
Classroom: Room ID, capacity, room type, facilities
Class: Class ID, Classroom ID, Subject ID, Teacher ID, Period, Time

Relationships:

Teacher teaches Subject
Student attends Class

Entities in a system like this are always singular. The entity describes the characteristics of one instance of the entity, a so-called entity occurrence.

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

What shape denotes an entity set?

A

A rectangle

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

What shape denotes an attribute?

A

An oval

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

What shape denotes a relationship?

A

A diamond

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

Primary Key Attributes (PK)

A

uniquely identify each entity occurrence, it is a field that is unique for each record within a table

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

Foreign Key Attributes (FK)

A

are found on the ‘many’ (or ‘one’ in a one-to-one) side of a relationship and always take the same values as the primary key attribute in a linked entity. They define the relationship.

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

Non-Key Attributes

A

describe characteristics of the entity

20
Q

Problems with many to many relationships? how to solve them?

A
  • Cause data redundancy (repeating data)
  • Can cause error if implemented within a database software
    To solve this, a bridging table can be added in between the two tables, called an associative entity which holds details of a single occurrence of the relationship between the two other entities
21
Q

Put this list into database notation called Customer with CustomerId as the primary key;
-Customer ID
-Title
-Forename
-AddressLine1
-Town

A

tblCUSTOMER(CustomerId, Title, Forename, AddressLine1, Town)
—————–

(Underline CustomerId as it is the PK, overline any FK)

This is a simple flat data structure

22
Q

Problems with flat file data structures

A
  • Inefficiency
  • Data Redundancy
  • Data Inconsistency
23
Q

Degree

A

Number of columns in a table

24
Q

Attribute/field

A

1 column in a table

25
Q

Domain

A

Allowed values

26
Q

Relation

A

Whole table

27
Q

Tuple

A

1 row

28
Q

Normalisation

A

Normalisation is the process of organising data in a database, through converting a single flat-file entity into multiple separate entities/relations/tables. Normalisation also includes the removal of redundant data

29
Q

1st Normal Form

A

Contains only atomic values (all or nothing) ;
NOT [red, green] à [Red],[Green]
I.e. each field (Colum) only has one value

  • There are no repeating groups [Author1], [Author2], [Author3])
  • Each row (Tuple/Record) holds unique set of data
    After 1NF data has been flattened

This may create issues because of the duplicated data:
- Insertion Anomaly: Cannot insert due to requiring certain attributes for the PL
- Update Anomaly: If the name of something is altered, many changes would be req.
- Deletion Anomaly: Losing information not intended when certain attribute is deleted

30
Q

2nd Normal Form

A

(in 1NF) and no partial dependencies on anything but the primary key.
Each column/field depends on the whole of the primary key

31
Q

3rd Normal Form

A

(in 2NF) and no transitive dependencies (Non primary attribute is dependent on another non primary attribute)
All data items must depend on nothing but the key
The primary key must fully define all non-key fields/column, and non-key fields/columns must NOT depend on any other Key but the primary key.

32
Q

What is a query language?

A

A query language is used when a user wants to search a database
Extract selected data from a database by stating criteria
E.g. SQL (Structured Query Language)
SQL can also create tables

33
Q

Data Definition Language (DDL)

A

Provides commands that allow you to define and modify a database and its components (e.g. tables, relationships)

34
Q

Data Manipulation Language (DML)

A

Provides commands that allow you to insert, update and delete data from a database

35
Q

Data Query Language (DQL)

A

Provides commands that allow you to retrieve data from a database

36
Q

SQL Operators

A

= Equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
<>, != not equal
BETWEEN - Between a range
LIKE - Search for a pattern
IN - Specify multiple possible values
ASC - Ascending order
DESC - Descending order
* - All

37
Q

SQL Commands

A

SELECT - Extracts data
UPDATE - Updates data
DELETE
INSERT INTO - Inserts new data
CREATE DATABASE
ALTER DATABASE
CREATE TABLE
ALTER TABLE
DROP TABLE
CREATE INDEX
DROP INDEX

38
Q

CHAR vs VARCHAR

A

CHAR;
Stores values in fixed lengths
Max 255 characters
Used when sizes of column data entries are consistent

VARCHAR;
Values variable length long, 1 byte or 2 byte length prefix
Max 65535 characters
Used when sizes of data entries change considerably

39
Q

Create SQL table:
Called Manager
with fields;
- ManagerId
- Firstname
- Surname
- Date of Birth

A

ANSWER
CREATE TABLE Manager
{
ManagerID CHAR(5) NOT NULL,
Firstname CHAR(20) NOT NULL,
Surname CHAR(20) NOT NULL,
DOB DATE NOT NULL,
PRIMARY KEY (Manager ID)
}

40
Q

Referential Integrity

A

If a value appears in a foreign key table, it must also appear in the primary key in another table. If a primary key of a record in one table is changed then it must be updated in all tables where it is used as a foreign key. To maintain referential integrity you need associations to avoid orphaned records

41
Q

Client Server Database

A

Provides simultaneous access to the database for multiple clients through Database Management Systems (DBMS) with server w software running on network server and client software

42
Q

Concurrent access

A

can result in the problem of updates being lost if two clients edit a record at the same time. This can be managed using record locks, serialisation, timestamp ordering and commitment ordering

43
Q

Record Lock

A

A technique that prevents simultaneous access to objects in database in order to prevent update being lot or arising data inconsistencies

44
Q

Serialisation

A

Ensures that transactions do not overlap in time and therefore cannot interfere with each other or lead to updates being lost and implemented using the Timestamp ordering

45
Q

Timestamp ordering

A

A timestamp is given to each transaction so that if 2 transactions affect the same object (record) the transaction with the darker timestamp would be applied first. To ensure data are not lost every object in a database has a read and write timestamp which are updated whenever an object is read or written

46
Q

Commitment ordering

A

Serialisation technique ensures safe transaction without any loss of data when >2 users are simultaneously accessing the same object in a database and ordered in terms of their dependencies on each other and the time they were initiated