Databases Flashcards

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

How can a many-to-many relationship be expressed?

A

By both tables in the relationship having one-to-many relationships to a common table

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

What is an entity?

A

A thing about which data is to be stored, for example: a customer. Each row in the table is an entity

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

What is an attribute?

A

Characteristics or other information about entities, for example: the customer’s name or address: Each column in the table is an attribute

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

What is a composite primary key?

A

A primary key made up of multiple attributes

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

What is a foreign key?

A

A key in a table which is the primary key in another table, used to link those two tables

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

What is a primary key?

A

A primary key is an attribute that provides an unique identifier for every entity in a table

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

[PPQ] What does it mean when a database is normalised?

A

The data is atomic and has no transitive dependencies [?}

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

What are the advantages of normalised databases?

A

Faster to search and sort, easier to manage, number of update, insertion and deletion anomalies reduced

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

What is first normal form?

A

When a database conforms to first normal form, it contains no repeating attributes. The database’s data can be referred to as atomic (meaning that no single column contains more than one value).

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

[PPQ] Describe an example of a problem that could occur if no system were in place to
manage concurrent access to the database

A

Two users read and edit the same record simultaneously. They both edit the record and then send it back and save, meaning only one set of changes is kept

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

What is second normal form?

A

Ensuring the database is in 1NF and removing attributes that depend upon part but not all of the primary key by creating additional tables

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

What is third normal form?

A

Ensuring the database is in 2NF and removing non-key attributes that depend on other non-key attributes

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

What is a client-server database?

A

A database that is stored on a server and can be accessed by various users from their workstations

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

How can simultaneous access problems be avoided?

A

Record locks: when a transaction on a record starts, there’s a temporary exclusive lock on that record, and other users cannot edit the data until the lock is removed

Timestamp ordering: Timestamps are generated for each transaction, database records timestamp of the last time the record was written to, and aborts the transaction if it will result in loss of data integrity

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

Creating a table

A
CREATE TABLE TableName
{
AttribName1 datatype (length),
AttribName2 datatype (length),
PRIMARY KEY (AttribName1)
};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Inserting values into a table

A

INSERT INTO TableName (AttribName1, AttribName2)

VALUES (“69”, “demoman”);

17
Q

Updating a table

A

UPDATE TableName
SET AttribName2 = “shrek”
WHERE Attrib1 = “69”;

18
Q

Deleting values from a table

A

DELETE FROM TableName
WHERE AttribName1 = “69”;

or

DELETE * FROM TableName;

19
Q

Querying data from a table

A

SELECT AttribName1, AttribName2
FROM TableName
WHERE AttribName2 = “shrek”
ORDER BY AttribName1 DESC

  • is the wildcard operator
    AND and OR can also be used
20
Q

Common errors in SQL code

A

Missing quotation marks, no linking condition between the two tables