Introduction to SQL - Introducing Queries Flashcards
Learn your first SQL keywords for selecting relevant data from database tables! After practicing querying skills in a database of books, you’ll customize query results using aliasing and save them as views so they can be shared. Finally, you’ll explore the differences between SQL flavors and databases such as PostgreSQL and SQL Server.
SQL is used to answer questions both within and across what?
relational databases tables
You should analyze data in a spreadsheet if what two conditions are met?
1) data can fit in a spreadsheet
2) does not relate to other data
What are keywords?
reserved words used to indicate what operations we want our code to perform
What are the two most common keywords?
SELECT and FROM
The SELECT keyword indicates what?
indicates which field should be selected from a table
The FROM keyword indicates what?
indicates the table in which the selected fields are located
What are 3 best practices with writing a query?
1) end query with a semicolon
2) capitalize keywords
2) keep tables/field names lowercase
The results of a query is called what?
a result set
True/False - Querying a databases with SQL changes the underlying database.
False - a query does not change the database itself or its tables rather it only changes the results
True/False - We can save the SQL we write so that our collaborators can use it to query the database themselves.
True
How can you change the order that fields are listed in the SQL output?
change the order of the field names after the SELECT keyword to change their order
How can you select all the fields from a table without listing them out?
SELECT *
What can we use to rename columns in SQL?
Aliasing
What keyword do we use to alias a column?
AS
What keyword do we use to get a list of records with only unique values?
SELECT DISTINCT
If we use DISTINCT with multiple fields what gets returned?
only unique combinations of the fields will be returned but the fields themselves may still have duplicate values
What is a view in SQL?
a saved SQL SELECT statement in the form of a virtual table
The data a view contains is not generally stored in a database, rather it is the what that gets stored for future use?
query code
What is a benefit of accessing views?
automatically updates when the data does
True/False - There is no result set when creating a view.
True
True/False - Once a view is created we can query it the same as a normal table by selecting from it.
True
True/False - Once a view is created we can query it the same as a normal table by selecting from it.
True
What are 5 characteristics of different SQL flavors?
1) both free and paid
2) all used with relational databases
3) majority of keywords are the same
4) all must follow universal standards
5) only the additions on top of these standards make flavors different
What are the two most popular flavors of SQL?
1) PostgreSQL
2) SQL Server
Where was PostgreSQL created? Who sponsored it?
University of California, Berkley that was sponsored by DARPA
Who created SQL Server?
Microsoft
What is Microsoft’s SQL flavor that is used with SQL server databases?
T-SQL
Comparing PostgreSQL and SQL Server is like comparing what?
dialects of the same language (English/UK)