SQL: Concepts, Vocab, Syntax Flashcards

(52 cards)

1
Q

What does SQL stand for?

A

Structured Query Language

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

What is SQL used for?

A

To manage data held in relational database management systems (RDBMS)

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

What type of data does SQL work with?

A

Structured data with relations among variables

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

What are the main scopes of SQL?

A
  • Data query
  • Data manipulation
  • Data definition
  • Data access control
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens if correct syntax is not used in SQL?

A

The SQL will return an error

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

What is the function of the SELECT clause in SQL?

A

To describe a set of data you want to retrieve from a database

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

What must be included in a SELECT statement?

A
  • What tables contain the data
  • How the data is related
  • Which fields or calculations will produce the data
  • Criteria for data inclusion
  • Sorting order for results
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of the FROM clause in SQL?

A

To identify the table where the fields specified in the SELECT clause are located

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

What is the most basic structure of a SELECT statement?

A
  • SELECT clause
  • FROM clause
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you select all columns from a table in SQL?

A

Use the asterisk (*) symbol in the SELECT clause

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

What does the WHERE clause do?

A

Specifies criteria to filter or limit the query results

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

Is the WHERE clause required in a SELECT statement?

A

No, it is not a required element

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

What are the AND and OR operators used for in SQL?

A

To add additional clauses following the initial WHERE clause

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

What does the ORDER BY clause do?

A

Sorts query results based on specified fields

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

What is the default sorting order in SQL?

A

Ascending order

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

How do you specify descending order in SQL?

A

Use the DESC keyword

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

What is the purpose of the JOIN clause in SQL?

A

To combine rows from two or more tables based on a related column

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

What are the types of JOINs in SQL?

A
  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL JOIN
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does an INNER JOIN do?

A

Returns records that have matching values in both tables

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

What does a LEFT JOIN return?

A

All records from the left table and matched records from the right table

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

What does a FULL JOIN return?

A

All records from both tables, with nulls in the columns where there are no matches

22
Q

What is the UNION operator used for?

A

To combine the result-sets of two or more SELECT statements

23
Q

What are the requirements for using the UNION operator?

A
  • Same number of columns
  • Compatible data types
  • Same order of columns in each SELECT statement
24
Q

What is a relationship in the context of SQL?

A

An association between common fields in two tables

25
What are the three types of relationships in SQL?
* One-to-one * One-to-many * Many-to-many
26
What is the difference between a relationship and a join?
A relationship is a logical association, while a join is an SQL operation that combines data from two sources
27
What must be used with the ON keyword in a JOIN clause?
The common column used to join the tables
28
What is a database?
An organized collection of related information
29
What defines a relational database?
Data is organized into one or more tables
30
What are fields in a database table?
Columns that define the nature of the data stored in the table
31
What is a record in a database?
One instance of a set of fields in a table
32
What are the two main components of a database table?
Records (rows) and fields (columns)
33
What is a field in the context of a database?
A single item of information or attribute that appears in every record
34
What are the benefits of good database design?
* Reduces or eliminates redundant data * Supports accuracy and integrity of information * Accommodates data processing and reporting needs * Stores information in its smallest logical parts
35
What is the first step in the database design process?
Determine the purpose of your database
36
What does normalization in database design aim to achieve?
Ensures information items are divided into appropriate tables
37
What is the 1st Normal Form (1NF)?
Each piece of data is in its own box, with no lists or groups in a single cell
38
What does the 2nd Normal Form (2NF) build upon?
1NF and ensures all information in a table relates only to the whole primary key
39
What is the primary key in a database?
A column used to uniquely identify each row
40
What is a foreign key (FK)?
A FK in one table is the primary key in another table
41
What is the difference between a primary key (PK) and a foreign key (FK)?
PK uniquely identifies a row; FK establishes a link to related columns in another table
42
What is a one-to-one relationship in databases?
A patient is assigned to one bed, and a bed is assigned to one patient
43
What is a one-to-many relationship?
One patient can have many visits, but each visit belongs to only one patient
44
What is a many-to-many relationship?
A patient may have many diagnoses, and each diagnosis may be associated with many patients
45
What is an Entity Relationship Diagram (ERD)?
A graphical representation of data requirements for a database
46
What are the three components of an ERD?
* Entities * Attributes * Relationships
47
Fill in the blank: A field's data type determines the _______.
[set of qualities that applies to all the values contained in the field]
48
What is the purpose of applying normalization rules?
To organize data better, avoid repetition, and make databases easier to update and maintain
49
What is the primary key often used as in database design?
A simple surrogate key, usually an integer (Autonumber)
50
True or False: A foreign key restricts the data that can be stored in the foreign key column based on the parent table.
True
51
What is the purpose of dividing information into subject-based tables in database design?
To reduce or eliminate redundant data
52
What should you do after creating tables in the database design process?
Add a few records of sample data