SQL Flashcards

1
Q

What is a Databse

A

An organized collection of data stored on a computer.

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

What does DBMS stand for

A

Database Management System

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

What does RDBMS stand for?

A

Relational Database Management System

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

What is SQL

A

SQL stands for Structured Query Language

It is the standard language used for accessing, and storing data from a database

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

Name some popular Relational Database Management Systems.

A
  • MySQL
  • Oracle
  • PostgreSQL
  • IBM DB2
  • MariaDB
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are Tables, Fields, and Records in an SQL Database?

A

A Table is an organized collection of data defined by the data’s model, that is organized in rows in columns
A field, or a table column, is a label that defines which data should be stored there for each record in the table
A Record, or table row, is a single set of data comprised of all the required fields of the table

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

List and describe all of the SQL Constraints

A

NOT NULL: Any value inserted in to this field cannot be NULL
CHECK: Verifies that the values of the affected field satisfy the stated condition
DEFAULT: Assigns a value to a field if no other value was assigned to it.
UNIQUE: For the field marked Unique, every record in the table must have a unique value.
INDEX: indexes a field for faster data retrieval
PRIMARY KEY: A unique field that is used to identify each individual record
FOREIGN KEY: A field that allows the database to link records across different tables.

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

How does a foreign key work?

A

When two tables contain related data, a foreign key is used to establish a link between the two tables.

When a relationship is created, the child table will receive a foreign key field and each record that has a relationship to a record on the parent table will have a foreign key that refers to the Primary Key Value of the parent record.

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

Describe the AS clause

A

Allows us to define a new name for a field when creating a join.

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

Describe an Inner Join

A

Compares all records from two tables and determines if any values of a specified column in table A match any values of a specified column in table B

Returns only the full records from both tables where the specified fields matched

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

Describe a Full Outer Join

A

Returns all data from both tables and matches the data records that have matching data in the specified field

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

Describe an Exclusive Outer Join

A

Opposite of an inner join

Will only return records where the data in the selected field does not have a match.

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

Describe an Asymmetrical Join or

A

Returns all records from table A and only records from table B where the data in the specified fields match

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

Describe an Exclusive Asymmetrical Join

A

Selects only the records from Table A that do not have matching data in the specified field in table B

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

What is the difference between left and right joins?

A

The only difference in SQL is the order that the tables are referenced.

In a Left Join, table A is referenced first and table B is joined on to table A

In a Right Join, Table B is referenced first and table A is joined on to table B

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

What is a Union statement

A

Used to directly combine data from two or more tables without any explicit data relationship

17
Q

What is a Sub-query

A

A sub query is a query that selects a set of records from a previous query or a query that uses a query that returns a single value (like a mathematical function query) in order to create a second query.

18
Q

What is a Self-Join

A

A self join only uses one table.

It is used to match the data of two related columns within the singular table.

19
Q

What is a cross join

A

A cross join between two tables will return a query that includes all possible combinations of each record in each table.