Databases Flashcards

1
Q

What is a data model?

A

An abstract description of the essential data within a given context and how the data is related.

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

What is an entity?

A

A district thing about which data must be stored.

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

What is an attribute?

A

A single property of an entity.

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

What is an entity identifier?

A

An attribute, or 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
5
Q

What is a composite entity identifier?

A

Multiple attributes are required to uniquely identify an instance of an entity

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

What do you need to know when designing a data model?

A
  • Data that will be stored
  • Real-Word entities that this data refers to
  • Relationships that exist between entities
  • Constraints that belong to the data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can a data model be visually presented?

A
  • Entity Description
  • Entity-relationship diagram
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an entity description?

A

Entity(Entity Identifier, Attribute, Attribute, Attribute)

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

What is a relationship in an E-R diagram?

A

Two-way association or link between two entities

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

What are the different types of relationships in an E-R diagram?

A
  • One-to-Many
  • Many-to-Many
  • One-to-One
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How are entities represented in E-R diagrams?

A

A rectangle with the name of the entity inside it. The name is always singular.

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

What is a Relational Database?

A

A collection of tables between which relationships are created through common attributes (primary and foreign keys)

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

What is a primary key?

A

An attribute that will uniquely identify a particular instance of an entity.

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

What is a composite primary key?

A

Two or more attributes which together uniquely identify a particular instance of an entity

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

What is a foreign key?

A

An attribute on one table which is the primary key attribute in another table

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

How can we store required data from a data model?

A
  • In an OOP language
  • Relational Databases
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How do we turn a data model into a relational database?

A

Entity —> Table
Attribute —> Field
Instance of an entity —> Record

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

What is a Flat File Database?

A
  • Simplest way of storing data in a text file (e.g. CSV)
  • Each line represents a record, with fields separated by commas
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are the advantages and disadvantages of flat file databases?

A

+ Easy to create and use for small databases
- Inefficient as the data grows

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

How does a relational database work?

A
  • Organises data across multiple tables
  • Tables related through common fields
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are the advantages of relational databases?

A
  • Scales better as a data set grows
  • Avoids data duplication/redundancy
  • Avoids data inconsistencies
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a data dictionary?

A
  • Description of the tables of a relational database
  • Presented as a table describing one entity/table in the database
  • Shows constraints on data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What are the main data types used in databases?

A
  • Integer
  • Float
  • Text - any length
  • Varchar(X) - maximum length X
  • Date
  • DateTime
  • Boolean
24
Q

What is the structure of a SELECT query?

A

SELECT field1, field2, field3..
FROM table
WHERE condition
ORDER BY fieldname ASC|DESC

25
Q

How is the LIKE key-word used in a query?

A

SELECT ….
WHERE fieldname LIKE “string%”

26
Q

What are the different ways you can use LIKE and placeholder values?

A

“%string” = ends with the string
“string%” = starts with the string
“%string%” = contains the string

27
Q

How can you use the BETWEEN key-word in queries?

A

SELECT … FROM …
WHERE date BETWEEN “01/01/2025” AND “31/01/2025”
(This is inclusive)

28
Q

How can you query multiple tables?

A

SELECT table1.field1, table1.field2, table2.field1
FROM table1 JOIN table2 ON table1.foreignKey = table2.primaryKey

29
Q

How do you update records in SQL?

A

UPDATE table
SET fieldname = value
WHERE condition

30
Q

How do you delete records in SQL?

A

DELETE FROM table WHERE condition

31
Q

How do you create a new table using SQL?

A

CREATE TABLE table_name
(
PrimaryFieldName dataType PRIMARY KEY,
Field1 dataType constraints,
Field2 dataType constraints,
)

32
Q

What are some typical constraints on fields?

A
  • NOT NULL
  • UNIQUE
  • PRIMARY KEY
  • DEFAULT
33
Q

How can you use INSERT INTO in an SQL query?

A

INSERT INTO tableName (field1, field2, field3)
VALUES (value1, value2, value3)

34
Q

What is data normalisation?

A

All non-key attributes depend upon the key, the whole key and nothing but the key (and there are no repeating groups)

35
Q

What is data redundancy?

A

Data that is unnecessarily duplicated within a database

36
Q

What is an update anomaly?

A

Inconsistent data as a result of updating multiple instances of the same data

37
Q

What can data redundancy result in?

A
  • Increased storage costs: require larger storage capacities, including backups
  • Reduced performance: makes queries much slower as more data to process
  • Data inconsistency
38
Q

What are the benefits of normalisation in databases?

A
  • Minimising data duplication
  • Eliminating data redundancy
  • Eliminating data inconsistencies
  • Easier to query
  • Easier to maintain
39
Q

What are the different degrees to which data can be normalised called?

A

Normal forms

40
Q

What is a client-server database?

A

A specific instance of a client-server application that provides simultaneous access to a database for multiple clients

41
Q

What is the lost update problem?

A

When two users attempt to update the same record simultaneously resulting in one of the updates being ‘lost’

42
Q

What is a record lock?

A

A ‘lock’ applied to the record when a transaction on the record starts

43
Q

What are the advantages of a client-server application model?

A
  • Data is stored in one place
  • Centrally managed and backed up
  • Data can be easily shared across client services
44
Q

Why is it better for data and resources to only be stored in one place in a client-server database?

A
  • There is no need for duplication and distribution of data
  • No redundant data
  • Risk of data integrity issues if data is out-of-date
45
Q

What are the disadvantages of the client-server application model?

A
  • Everything could be lost or inaccessible if the server is unavailable
  • Simultaneous access of resources can cause congestion and poor performance
  • Multiple user access for a resource can result in conflict
46
Q

What are some ways to deal with the lost update problem?

A
  • record locks
  • serialisation
  • timestamp ordering
  • commitment ordering
47
Q

What are the disadvantages of record locks?

A
  • They can result in deadlock
  • They do not scale well for large databases
48
Q

What is concurrent access?

A

When different users try to access the same record at the same time

49
Q

What does 1st normal form require?

A
  • Atomic data
  • Each record has a primary key
  • No repeating groups
  • No duplicated records
50
Q

What does 2nd normal form require?

A
  • 1st normal form
  • No partial key dependencies
51
Q

What does 3rd normal require?

A
  • 1st and 2nd normal form
  • No transitive partial key dendancies
52
Q

What is atomic data?

A

Data that has been fully decomposed into multiple attributes

53
Q

What are repeating groups?

A

Two or more fields store data for the same attribute with a single record

54
Q

What are partial key dependencies?

A

When there is a composite key, not all non-key attributes relate to the whole key

55
Q

What are transitive partial key dependencies?

A

Non-key attributes that depend/relate to other non-key attributes