Introduction to SQL - Relational Databases Flashcards

Before writing any SQL queries, it’s important to understand the underlying data. In this chapter, we’ll discover the role of SQL in creating and querying relational databases. Using a database for a local library, we will explore database and table organization, data types and storage, and best practices for database construction.

1
Q

What type of database defines the relationship between tables of data inside the database?

A

Relational Databases

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

What are the 3 advantages of a database over a spreadsheet?

A

1) more storage
2) more encryption
3) multiple users

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
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
4
Q

Table names should follow what 3 rules?

A

1) lowercase
2) have no spaces - use underscores
3) plural

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

What is a record?

A

a row that hold data on an individual observation

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

What is a field?

A

a column that holds one piece of information about all records

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

Field names should follow what 5 rules?

A

1) lowercase
2) no spaces
3) singular
4) different from field names
5) different from the table name

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

Unique identifiers are used to identify what?

A

records in a table

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

What is a feature of unique identifiers (IDs) apart from being unique?

A

they are often numbers

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

Having more tables each with a clearly marked subject is generally better than what?

A

having fewer tables where information is combined

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

What are the 2 reasons we use data types?

A

1) different storage requirements
2) some operations only apply to certain types

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

What is the definition of a string?

A

a sequence of characters such as letters or punctuation (or numbers with special characters)

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

What is a popular string data type in SQL?

A

VARCHAR

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

What does an integer store?

A

whole numbers

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

What is a popular integer data type in SQL?

A

INT

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

What do floats store?

A

numbers that include a fractional part

17
Q

What is a flexible and popular float data type in SQL?

A

NUMERIC

18
Q

Schemas are often referred to as what?

A

the blueprints of databases

19
Q

What 3 things does a schema show about a databases design?

A

1) it’s tables
2) relationships between its tables
3) data type in tables

20
Q

What are the 3 most common data types in SQL and their respective descriptions?

A

1) VARCHAR - text strings
2) INT - whole numbers
3) NUMERIC - decimals

21
Q

What data type would be best suited for this example? Product prices in dollars such as 63.75?

A

NUMERIC

22
Q

What data type would be best suited for this example? Weight in tons such as 5.67

A

NUMERIC

23
Q

What data type would be best suited for this example? Phone number such as 321-123-5555

A

VARCHAR

24
Q

What data type would be best suited for this example? Model year such as 2004

A

INT

25
Q

What data type would be best suited for this example? Number of mailing list subscribers such as 9782

A

INT

26
Q

What data type would be best suited for this example? Product reviews written by customers

A

VARCHAR