SQL Flashcards

1
Q

What are DML, DDL, DCL and TCL?

A

Data Definition Language
Data Manipulation Language
Data Control Language
Transaction Control Language

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

What is an ERD?

A

An entity relationship diagram is a type of flowchart that illustrates how entities relate to each other within a system

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

What is a primary key?

A

It’s the column or columns that contain values that uniquely identify each row in a table.

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

What is a foreign key?

A

It is a set of attributes in a table that refers to the primary key of another table. The foreign key links these two tables.

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

What is the difference between a foreign and primary key?

A

Primary key doesn’t accept null values but the foreign key does.

There is only one primary key in a table but multiple foreign keys can exist.

Foreign key can contain duplicate values.

The value of a primary key cannot be removed from the parent table whereas the value of a foreign key value can be removed from child table.

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

What is a wildcard?

A

A wildcard character is used to substitute one or more characters in a string. They are used with the LIKE operator.

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

What is concatenation (with example)?

A

The operation of joining character strings end-to-end?

SELECT CONCAT(‘SQL’, ‘ is ‘, ‘ fun! ‘);

Output: SQL is fun!

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

When is the GROUP BY keyword used?

A

It is used to arrange identical data into groups with the help of some function.

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

Explain Normalisation?

A

Normalisation is the process of organising data in the database. It is used to minimise the redundancy from a relation or set of relations. The large table is divided into a smaller table and links them using relationship.

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

What are the rules of the normal forms?

A

1NF (First Normal Form):
The data must be atomic (single value)
Each row must be unique
No repeated groups

2NF (Second Normal Form):
Already in First normal form
All non-key attributes must functionally depend upon the full primary key.

3NF (Third Normal Form):
Already in Second Normal Form
There no transitive dependencies

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