Databases Flashcards

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

Entity-Relationship Modelling

A

A method of abstractly describing the data tables and the relationships between them visually. They can be used to reduce redundancy and construct a relational database.

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

What is an entity?

A

It is a thing about which data is to be stored, for example: a customer.

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

What is an attribute?

A

Attributes are characteristics or other information about entities, for example: the customer’s name or address.

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

What is a relational database?

A

It is a type of database that stores and provides access to data points that are related to one another.

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

What is a primary key?

A

A primary key is an attribute that provides an unique identifies for every entity in a database table.

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

What is a composite key?

A

If it is not possible to form a primary key from just one attribute. It is possible to combine attributes to form what is called a composite primary key

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

What is a foreign key?

A

A foreign key is an attribute in a table which is the primary key in another, related, table.

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

What is a one-to-one relationship?

A

Where one entity could be linked to only one of another entity

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

What is a one-to-many relationship?

A

Where one field from a table is linked to several records from another table.

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

What is a many-to-many relationship?

A

For example, a tutor might have multiple students and students might have multiple tutors. This type of relationship can become complicated when turned into a database because they cannot occur in real life; data cannot be transferred as it logically doesn’t make sense. This can be fixed using an association table. For example, a tutor can publish many papers and a paper can have many publishers so the association is Publication Issue Number; this is because it’s the simplest link.

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

What is normalisation?

A

Normalisation is the process of removing redundancy within a database. Doing so makes accessing and storing data easier and more efficient

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

Steps for Un-normalised Form

A
  1. Select an initial key. This acts as a starter key. It needs to be unique so you can derive other values from it. If there is no suitable key, add one.
  2. Transfer all identifiable attributes, ensuring each has their own relevant and unique name.
  3. Look for repeating groups. These are a group of similar attributes that have multiple values for a single value of the initial key. Select a suitable initial key for the repeating group, surround them with brackets, and write them apart from the single-valued attributes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Steps for First Normal Form

A
  1. Create new relations by separating all repeating groups select a new primary key for the new relation and propagate the initial key to form a new composite key.
  2. All other single-values attributes remain with the initial key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Steps for Second Normal Form

A

The second stage of normalisation requires that all key attributes in a table are dependent on each other and that the table is in first normal form. Only then can you move on to creating a database that is in second normal form which will provide even more strength to the data structure.

  1. Separate any attributes from keys formed in the previous step that are only dependent on one part of the composite key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Steps for Third Normal Form

A

The third step is the transition into third normal form.

  1. Separate any attributes that are dependent on other non-key attributes; foreign keys are retained in the original relation
  2. Check composite keys for redundant parts. If a part of a key can be derived from other attributes, demote key attribute to non-key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Advantages of normalisation

A

no redundancy, consistent data throughout linked tables, records can be added and removed without issues, complex queries can be carried out

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

What is SQL?

A

Structured Query Language is a declarative language used for querying and updating tables in a relational database.

17
Q

What are the two types of SQL?

A

Data Definition Language, Data Manipulation Language

18
Q

What is DDL?

A

The data definition language is a language used to build the structure of a database, and consists of a variety of commands which allow the user to define the structure of the database by creating, altering or deleting tables. It also allowed the administrator to apply constraints to a database table.

19
Q

What is DML?

A

The data manipulation language is the language used to populate and update the database after it has been created. DML allows the user to insert, modify, delete, and query a database table for the data values of the entire table, for a specific record or for records that meet criteria.

20
Q

VARCHAR(n)

A

Variable length string of maximum n characters

21
Q

CHAR(n)

A

Fixed length string of n characters

22
Q

DATE

A

A date (there is also TIME, TIMESTAMP, and DATETIME)

23
Q

INT

A

Whole numbers (positive and negative)

24
Q

BOOLEAN

A

TRUE/FALSE

25
Q

DECIMAL (n,d)

A

Fixed-point decimal number with n digits in total, d is the number of digits after the decimal point

26
Q

DOUBLE (n,d)

A

Floating-point decimal number with n digits in total, d is the number of digits after the decimal point

27
Q

ENUM

A

List of permitted values (encoded as numbers)

28
Q

BLOB

A

Binary data (such as an image)

29
Q

TEXT

A

For large quantities of text

30
Q

How do you create a table?

A

CREATE TABLE tablename(
Entity1 DATATYPE(n),)

31
Q

How do you define a primary key?

A

PRIMARY KEY (MemberId, CourseCode)

32
Q

How do you define a foreign key?

A

FOREIGN KEY (name) REFERNCES

33
Q

How do you alter a table structure?

A

Used to add, delete or modify columns in an existing table:

ALTER TABLE tablename
ADD nnnn INTEGER

34
Q

Delete or alter a table structure

A

To delete a column
ALTER TABLE tablename
DROP mmmm

TO change the data type of a column:
ALTER TABLE table name
MODIFY COLUMN n DATAYPE(n) NOT NULL

35
Q

How do you SELECT FROM WHERE ORDER BY

A

SELECT productID, productName, subject, price
FROM tblProduct
WHERE level = 4
ORDER BY productNAME

36
Q

Updating data

A

UPDATE Product
SET Description = “mmlMK”, Price = “njnomom”
WHERE ProductID = “A345”

37
Q

Deleting

A

DELETE FROM Product
WHERE ProductID = “A345”

38
Q

What are client server databases?

A

The client can be a node on a network, an individual computer or someone sat on the opposite site of the planet and the structure still works the same. the idea is that a client requests data from another program (the server) by a connection made over a wide area network or over a local area network. Once the data request is fulfilled, the connection is terminated.

39
Q

Advantages of client-server

A

Centralisation - allows server admins to decide the inf