SQL Flashcards

1
Q

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. The purpose of Normalisation in SQL is to eliminate redundant (repetitive) data and ensure data is stored logically.

I.e. 
1NF (First Normal Form)
2NF (Second Normal Form)
3NF (Third Normal Form)
BCNF (Boyce-Codd Normal Form)
4NF (Fourth Normal Form)
5NF (Fifth Normal Form)
6NF (Sixth Normal Form)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

DDL commands

A

Data Definition Language simply deals with descriptions of the database schema and is used to create, modify and delete the structures of database objects, but not the actual data itself.

  • Create:
    used to create the database or its objects
  • Drop:
    used to delete objects from the database.
  • Alter:
    used to alter the structure of the database.
  • Truncate:
    used to remove all records from a table, including all spaces allocated for the records are removed.
  • Comment:
    used to add comments to the data dictionary.
  • Rename:
    used to rename an object existing in the database.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

DQL commands

A

Data Query Language is a component of a SQL statement that allows the programmer to perform queries on the data within a schema from a database and, also, allows the programmer to impose order upon it.

Select:
used to retrieve data from the database.

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

DML commands

A

Data Manipulation Language is the component of a SQL statement that controls access to data and to the database itself, and generally deals with the manipulation of data.

  • Insert:
    used to insert data into a table.
  • Update:
    used to update existing data within a table.
  • Delete:
    used to delete records from a database table.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

DCL commands

A

Data Control Language includes commands which mainly deal with the rights, permissions, and other controls of the database system.

  • Grant:
    gives users access privileges to the database.
  • Revoke:
    withdraws the user’s access privileges given by using the GRANT command.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

TCL commands

A

Resources claim there to be another category of SQL clauses that deal with transactions in the database known as Transaction Control Language.

  • Commit:
    Commits a Transaction.
  • Rollback:
    Rollbacks a transaction in case of any error occurs.
  • Savepoint:
    Sets a savepoint within a transaction.

-Set Transaction:
Specify characteristics for the transaction.

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

ROWID (related to Normalization)

A
  1. ROWID is nothing but Physical memory allocation
  2. ROWID is permanent to that row which identifies the address of that row.
  3. ROWID is 16 digit Hexadecimal number which is uniquely identifies the rows.
  4. ROWID returns PHYSICAL ADDRESS of that row.
  5. ROWID is automatically generated unique id of a row and it is generated at the time of insertion of row.
  6. ROWID is the fastest means of accessing data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

ROWNUM (related to Normalization)

A
  1. ROWNUM is nothing but the sequence which is allocated to that data retrieval bunch.
  2. ROWNUM is temporarily allocated sequence to the rows.
  3. ROWNUM is numeric sequence number allocated to that row temporarily.
  4. ROWNUM returns the sequence number to that row.
  5. ROWNUM is an dynamic value automatically
    retrieved along with select statement output.
  6. ROWNUM is not related to access of data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

SQL functions

A

A function is a code snippet that can be executed on a SQL Server.

  • There are 2 types of functions in SQL:
    1. User-Defined function: User-defined functions are create by a user.
    2. System Defined Function: System functions are built-in database functions.
  • Rules for creating functions:
  • A function must have a name and a function name can never start with a special character such as @, $, #, and so on.
  • Functions only work with select statements.
  • Functions can be used anywhere in SQL, like AVG, COUNT, SUM, MIN, DATE and so on with select statements.
  • Functions compile every time.
  • Functions must return a value or result.
  • Functions only work with input parameters.
  • Try and catch statements are not used in functions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

aggregate functions

A
  • COUNT counts how many rows are in a particular column.
  • SUM adds together all the values in a particular column.
  • MIN and MAX return the lowest and highest values in a particular column, respectively.
  • AVG calculates the average of a group of selected values.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

joins

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

left join

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

inner join

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

outer join

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

right join

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

full join / full outer join

A
17
Q

truncate vs delete

A
18
Q

having

A
19
Q

where

A
20
Q

varchar vs char

A