Save
Upgrade to remove ads
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

DATABASE - 2

Advanced SQL

QuestionAnswer
is used to combine rows from two or more tables based on a related column between them (usually a primary key and a foreign key). SQL JOIN
Why Do We Use JOIN? In a relational database
is stored in multiple tables Data
are connected using keys. Tables
allows us to retrieve related data in a single query. JOIN
Types of SQL JOIN Types of SQL JOIN
Matching rows only INNER JOIN
All left + matching right LEFT JOIN
All right + matching left RIGHT JOIN
All rows from both tables FULL JOIN
All possible row combinations CROSS JOIN
Basic Structure of JOIN: SELECT column 1, column,2 FROM table1 JOIN table2 ON table1.column = table2.column;
Returns only the rows where there is a match in both tables based on a related column. INNER JOIN
SELECT a. account_number, s.firstName, s.lastName, s.course, a.active FROM Accounts a INNER JOIN students s ON a.student_id = s.id; INNER JOIN
Returns all rows from the left table Returns matching rows from the right table f there is no match → NULL values are shown LEFT JOIN
Returns all rows from the right table • Returns matching rows from the left table • If there is no match → NULL values appear in left table columns RIGHT JOIN
Returns all matching rows • Returns all unmatched rows from the left table • Returns all unmatched rows from the right table • Displays NULL when no match exists “FULL JOIN = LEFT JOIN + RIGHT JOIN combined FULL JOIN (FULL OUTER JOIN)
is a SELECT statement that is written inside another SQL statement. It is also called _____ AND _____ Subquery - inner query - Nested query
Types of Subqueries Types of Subqueries
returns a single column and a single row, that is, a single value. Scalar subquery
returns multiple columns, but only a single row Row subquery
returns one or more columns and multiple rows. Table subquery
is a database object that improves the speed of data retrieval operations on a table. Index
• Instead of scanning the whole table. • The database quickly locates the data. Index
The database checks every row (Full Table Scan) Without index:
The database directly jumps to the correct location. With index:
automatically have indexes Primary Keys
INSERT, UPDATE, DELETE Too many indexes can slow down
determines the physical order of data in a table. The table rows are stored in sorted order based on the indexed column. Clustered Index
Only one clustered index per table • Physically sorts the table • Usually created on the primary key • Fast for range queries Key Characteristics of Clustered Index
creates a separate structure that stores indexed column values and pointers to actual table rows. Non-Clustered Index
is a virtual table based on the result of a SELECT query View
It does not store data physically. • Instead, it stores the query definition. View
When you query a View, the database executes the stored SELECT statement View
Created by: user-1782765
 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards