SQL Flashcards
What are DML, DDL, DCL and TCL?
Data Definition Language
Data Manipulation Language
Data Control Language
Transaction Control Language
What is an ERD?
An entity relationship diagram is a type of flowchart that illustrates how entities relate to each other within a system
What is a primary key?
It’s the column or columns that contain values that uniquely identify each row in a table.
What is a foreign key?
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.
What is the difference between a foreign and primary key?
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.
What is a wildcard?
A wildcard character is used to substitute one or more characters in a string. They are used with the LIKE operator.
What is concatenation (with example)?
The operation of joining character strings end-to-end?
SELECT CONCAT(‘SQL’, ‘ is ‘, ‘ fun! ‘);
Output: SQL is fun!
When is the GROUP BY keyword used?
It is used to arrange identical data into groups with the help of some function.
Explain Normalisation?
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.
What are the rules of the normal forms?
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