SQL Part 1 Flashcards

1
Q

Explain what SQL is.

A

SQL stands for Structured Query Language. SQL lets you access and manipulate databases. SQL is the standard language for Relational Database System

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

What are some SQL databases?

A

Oracle.
PostgreSQL.
Microsoft SQL Server.
MariaDB.
IBM Db2.
Amazon Aurora.
Google Cloud Spanner.

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

What are the 5 sublanguages of SQL? Which commands correspond to them?

A

DDL
(Data Definition Language),

DML
(Data Manipulation Language),

DQL/DRL
(Data Query Language),

DCL
(Data Control Language),

TCL
(Transaction Control Language)

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

Which commands correspond to them?

A

DML
INSERT, UPDATE, DELETE

DDL
CREATE, DROP, RENAME, TRUNCATE, ALTER

DCL
GRANT, REVOKE

TCL
COMMIT, ROLLBACK, SAVEPOINT

DQL
SELECT

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

What is the difference between DELETE, DROP, and TRUNCATE commands?

A

The DELETE command deletes one or more existing records from the table in the database

The DROP Command drops the complete table from the database.

The TRUNCATE Command deletes all the rows from the existing table, leaving the row with the column names.

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

What are some SQL clauses you can use with SELECT statements?

A

SELECT – the columns in the result set.

FROM – names the base table(s) from which results will be retrieved.

WHERE – specifies any conditions for the results set (filter)

ORDER BY – sets how the result set will be ordered.

LIMIT – sets the number of rows to be returned.

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

What is the difference between WHERE and HAVING?

A

WHERE Clause is used to filter the records from the table based on the specified condition.

HAVING Clause is used to filter record from the groups based on the specified condition.

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

Explain what the ORDER BY and GROUP BY clauses do

A

The Group By clause is used to group data based on the same value in a specific column.

The ORDER BY clause, on the other hand, sorts the result and shows it in ascending or descending order

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

Explain the concept of relational integrity

A

the set of rules that can be used to maintain the data integrity during an insert, delete and update operations into a table. These constraints are checked in the database before performing any operation such as insertion, deletion, and updation on the tables

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

List the integrity constraints

A

entity integrity, referential integrity and domain integrity

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

Define the word “schema”

A

a schema is a list of logical structures of data

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

What is a candidate key?

A

A candidate key is a specific type of field in a relational database that can identify each unique record independently of any other data.

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

What is a surrogate key?

A

Surrogate Key in SQL Server is a unique identifier for each row in the table.

It is the sequential number outside of the database that is made available to the user and the application or it acts as an object that is present in the database but is not visible to the user or application.

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

What conditions lead to orphan records?

A

An orphan record is when a child record with a foreign key points to a parent record of a primary key field that no longer exists.

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

What are some SQL data types?

A
  1. Numeric data types such as int, tinyint, bigint, float, real, etc.
  2. Date and Time data types such as Date, Time, Datetime, etc.
  3. Character and String data types such as char, varchar, text, etc.
  4. Unicode character string data types, for example nchar, nvarchar, ntext, etc.
  5. Binary data types such as binary, varbinary, etc.
  6. Miscellaneous data types - clob, blob, xml, cursor, table, etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is normalization?

A

Normalization is a database design technique that reduces data redundancy and eliminates undesirable characteristics like Insertion, Update and Deletion Anomalies. Normalization rules divides larger tables into smaller tables and links them using relationships.

17
Q

What are the levels of normalization?

A
  1. First Normal Form (1 NF)
  2. Second Normal Form (2 NF)
  3. Third Normal Form (3 NF)
  4. Boyce Codd Normal Form or Fourth Normal Form ( BCNF or 4 NF)
  5. Fifth Normal Form (5 NF)
  6. Sixth Normal Form (6 NF)