Become A SQL Developer (LinkedIn) Flashcards

1
Q

What is CRUD?

A

Create, Read, Update, Delete

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

What does ACID relate to?

A

It relates to completing a transaction so that all elements are completed or none at all e.g. debiting a bank account and crediting another

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

What does ACID stand for?

A

Transactions should follow a set of principles. Transactions must be:

Atomic - the transaction is indivisible. It cannot be separated out.

Consistent - whatever the transaction does, it must leave the database in a valid or consistent state. Integrity should not be violated.

Isolated - while the activities in the transaction are being completed, nothing else can make changes to the data involved.

Durable - the information that we change during the transaction, actually gets written to the database.

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

What is a transaction?

A

It’s a type of setup that tells the RDBMS that all CRUD elements must be complete or none at all.

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

What’s the first step in building the database?

A

Ask what data it needs to store. What are the entities, attributes, datatypes, and keys (primary, foreign and composite?

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

What kind of diagram is good for a database?

A

Entity Relationship Diagram (ERD)

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

What are the naming conventions for table and attribute names

A

Table name - Start with a capital letter and use the plural as in Customers

Attributes - use upper camel case and use singular

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

What’s the difference between CHAR and VARCHAR

A

VARCHAR will store up to the number of characters you tell it but CHAR will reserve that amount in memory every single time - a huge impact when dealing with very large databases.

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

What are two data types that we can use for the date - what’s the difference?

A

DATE and DATETIME - the latter stores the time also

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

Show a decimal datatype with 3 digits before the decimal and 2 after?

A

DECIMAL(3,2)

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

What does NULL mean?

A

It means the absence of a value

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

What are the next steps (step 2) in creating the database?

A

Start looking at the relationships between the tables/entities.

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

What is a one to many relationship.

A

It is where one row of a table connects to more than one row of another table e.g. a customer table and food dishes table. A food dish can appear many times on the customer’s tables (when we log their favourite dish). One dish may be the favourite of many customers. The foreign key will be on the many side i.e. on the customer’s side. It will appear many times in the customers table (in the favourite dish column)

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

What is a cascading delete?

A

Is where you delete a record and the database goes on and deletes other records associated with that record?

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

What is the third step in creating the database?

A

Normalize the database

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

What is 1NF?

A

It requires that we have only one value in any one cell. It should not contain composite or multivalued entries.
We should also not have repeating groups in the table i.e. columns that contain the same type of data e.g. favourite dishes from the menu e.g. fav1, fav 2 etc. You can also just put in fav’s and put in all the favourite dishes - both are violations of 1NF.
Each row in the table must also contain a unique set of values.

17
Q

What is 3NF?

A

Values should not be stored if they can be calculated from another non-key field.

3NF tells you that each field in a row should represent something unique about a record

18
Q

What is denormalization?

A

The process of intentionally breaking the normalization rules.

19
Q

When is it appropriate to denormalize a database and why would you do it?

A

After normalization has occurred. It is not an excuse to skip normalization. We do it because e.g. if might be very resource costly to calculate a value by gathering lots of information from lots of different tables. Instead of doing this, we might just include a calculated value as a column in one of the tables.

20
Q

What is 2NF?

A

Ensure that a non-key field is not dependent on only part of a composite key (if it is then you will probably need to create another table with the part and the non-key field).