(4.10) Fundamentals of databases Flashcards

(23 cards)

1
Q

What is an entity?

A

An entity is something about which data is stored

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

What is an attribute?

A

Characteristics or other info about entities

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

What is an entity identifier?

A
  • In a database, each entity requires a unique identifier
  • an entity id is an attribute for an entity, which is unique within that table
  • sometimes entity ids are multiple attributes for uniqueness
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an entity description?

A
  • An entity description describes how data will be stored about entities
  • Underlining shows the attribute/s that form the entity identifier

ex.
Contacts (Name, PhoneNumber, Email, Age, etc..)

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

Relational databases: how are tables linked together?

A

Relational databases link tables together using common attributes (relational keys), there are 3 types of relationship:
* one-to-one
* one-to-many
* many-to-many

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

Entity relationship diagrams

A
  • entity relationship diagrams show the relationships between tables
  • one-to-one : ——
  • one-to-many : —–<
  • many-to-many : >—–<
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Primary and foreign keys: what are they?

A

A Primary key is an attribute that is a unique identifier for every entity in a table, e.g. an IDNumber

when tables are linked by attributes, the attribute must be a primary key in one table and a foreign key in the other

A Foreign key is an attribute in a table which is a primary key in another, related, table

attributes can be combined to form a composite primary key

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

What has to be created when linking a many-to-many relationship?

A

When linking a many-to-many relationship you have to create a new link table

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

Why are databases normalised and how?

A

Databases are normalised so that they can be efficient while keeping the data accurate and reliable:
* Allows for faster searching and sorting
* They are easier to maintain
* Duplication of data is lower and higher data consistency
* reduces the number of update, insertion and deletion anomalies

Normalising involves ensuring entities have no repeated or redundant data

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

Databases: what is first normal form?

A
  • Doesn’t contain any repeating attributes
  • Has atomic data (no column has more than one value)
    ex. phone number is atomic, whereas Firstname, Lastname is not
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Databases: what is second normal form?

A
  • All of first normal form (No repeating attributes, atomic data)
  • Has no partial key dependencies
    (this is when a non-key attribute doesn’t depend on the whole of the composite key)

E.g. a table called CourseEnrollment:

StudentID, CourseID, StudentName, CourseName

  • StudentName depends only on StudentID
  • CourseName depends only on CourseID

How to fix this:
Student(StudentID, StudentName)

Course(CourseID, CourseName)

Enrollment(StudentID, CourseID)

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

Databases: what is third normal form?

A
  • All of first normal form (No repeating attributes, atomic data)
  • All of second normal form (partial key dependencies removed )
  • Has no non-key dependencies

(All non-key attributes depend on the key, the whole key and nothing but the key)

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

Client server databases: what do they do?

A
  • Client server databases provide simultaneous access to a database for multiple users
  • When different users try to access the same field at the same time, concurrent access occurs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is concurrent access?

A

Concurrent access is the problem of
updates being lost if two clients edit a record at
the same time

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

How can concurrent access be fixed?

A

Concurrent access can be managed
by:

  • record locks - while one user is using a record, it is locked to other users
  • serialisation - requests to edit a record are queued
  • timestamp ordering - each command is assigned a timestamp, marking when it was initiated
  • commitment ordering - an algorithm is used to work out an optimum order, taking into account the impact of the command on the rest of the database
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a declarative language?

A

The programmer describes the result that is required rather than the process that should be followed

17
Q

SQL: SELECT

A
  • Used to retrieve data

SELECT < attribute > FROM < table > WHERE < condition > ORDER BY < ASC/DESC >

(order by is optional)

18
Q

SQL: UPDATE

A
  • Used to modify the attributes of an existing entity

UPDATE < table > SET < attribute > = < value > WHERE < attribute > = < value >

19
Q

SQL: DELETE

A
  • Used to remove entities

DELETE FROM < table > WHERE < condition >

20
Q

SQL: INSERT

A
  • Used to add new records to an existing table

INSERT INTO < table > (< column1 >, < column2 >, …) VALUES (< value1 >, < value2 >, …)

but can be simplified to

INSERT INTO < table > VALUES (< value1 >, < value2 >, …)

when all of the columns in the table are being used in the correct order.

21
Q

SQL: Wildcards

A
  • Can be used in SQL to specify any possible value
    (*)
22
Q

Defining a table with SQL

A
  • The CREATE command allows new tables to be made within a database
  • It specifies: the name, its attributes, their data types
  • Entity identifiers are also specified (primary & secondary keys)
23
Q

SQL data types (for defining tables)

A
  • Fixed length string - CHAR(size)
  • Variable length string - VARSIZE(size)
  • Integer - INT(size)
  • Number with fractional part - FLOAT(size, precision)
  • Date - DATE
  • Date and time - DATETIME
  • Time - TIME
  • Year - YEAR