Databases Flashcards

1
Q

What is SQL

A

Structured Query Language

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

CREATE

A

Used to create a new table (or database)

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

What is a database?

A

Is a persistent collection of related data stored in a structured way

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

What are the 3 characteristics of a data base

A

-There are tools to query (search, sort, filter) data.

-Databases are made up of entities (Tables)

-Each able contains fields and records.

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

What is a flat database

A

Stores all data in one table / entity

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

What are the pros and cons of a flat file database

A

+Use database tools to filter / sort

-we might encounter data integrity issues (when you cant trust your data)

-This could happen as you store something in different ways more then once (when you store things more then once its called data redundancy)

-data redundancy might lead a larger database then necessary

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

What is a secondary key?

A

A field that is an alternative Primary Key (also unique)

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

What is a primary Key

A

A field that uniquely identifies a record

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

What is a foreign key?

A

A primary key from another table, used to maintain a relationship

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

What is data integrity?

A

When you can’t trust your data, there could be inconsistencies (tends to happen when there is redundant data)

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

What is data redundancy?

A

When we stored duplicate data

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

What are the types of relationships in an ER diagram

A

-One to one
-many to one
-many to many

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

How do you delete a table or database

A

DROP

(DROP TABLE testTable;)

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

How do you add a new record to a table?

A

INSERT

INSERT INTO testTable (custID, first_name)
VALUES (1, “tim”);

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

How do you add a new record to a table?

A

INSERT

INSERT INTO testTable (custID, first_name)
VALUES (1, “tim”);

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

How do you change the values inside of a table

A

UPDATE

UPDATE testTable
SET first_name = “Rehan”
WHERE custID = 2;

17
Q

How do you delete records from a table?

A

DELETE

DELETE custID =1;

18
Q

How do you extract data from the table?

A

SELECT

SELECT firstname, surname
FROM Customer
WHERE CustomerID > 10 AND CustomerID < 15

19
Q

What is a indexed field?

A

A field that contains an index for faster searching

20
Q

What is referential integrity?

A

A related record is required in another table (always on the Foreign Key, there must be a related record in the table where it is the Primary Key
For example, you can’t book a roomNo that doesn’t exist

21
Q

What is normalisation?

A

The process of arranging fields into different tables

22
Q

what is 1st normal form

A

-If every field stores 1 item of data (atomic)
-if groups of data are stored as separate entities (tables)
-if each table has PK

23
Q

2nd normal form

A

-if already 1NF
-no partial dependencies (this can only happen when there is a composite key)