Coding Bootcamp: Inner & Outer Joins and Aggregates

SQL Joins

SELEECT Statement

WHERE Clause

SQL WHERE Syntax

SELECT column_name,column_name
FROM table_name
WHERE column_name operator value;

WHERE Clause

Example

SELECT *
FROM Customers
WHERE Country='Mexico';

GROUP BY Statement

SQL GROUP BY Syntax

SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name;

GROUP BY Statement

Example

SELECT customer_id, count(*) 
FROM Customers 
GROUP BY customer_id;

SQL Join

Example 1

Example 1

Example 1 - Query 1

Example 1 - Query 2

Inner Joining 3 tables

SELECT *
FROM Student
INNER JOIN Grade
    ON Student.ID = Grade.ID
INNER JOIN Course
    ON Grade.Code = Course.Code;

Inner Joining 3 tables

Example 1 - Query 2

Example 2

Example 2 - Query 1

Example 2 - Query 2

Example 2 - Query 3

Example 2 - Query 4

Sakila Sample Database

Sakila Sample Database

Sakila Sample Database

Sakila Sample Database

Sakila Sample Database

Sakila Sample Database

Sakila Sample Database

Sakila Sample Database

Sakila Sample Database

How to see the database schema

Data Base Schema – Reverse Engineering

Data Base Schema – Reverse Engineering

Data Base Schema – Reverse Engineering

Sakila – DB Schema

Sakila – DB Schema

Exercise 1

Exercise 2

Exercise 3

Exercise 4 (1/2)

Exercise 4 (2/2)

Exercise 5 (1/2)

Exercise 5 (2/2)

Exercise 6 (1/2)

Exercise 6 (2/2)

Exercise 7 (1/2)

Exercise 7 (2/2)

Exercise 8 (1/2)

Exercise 8 (2/2)

Exercise 9 (1/2)

Exercise 9 (2/2)

Exercise 10 (1/2)

Exercise 10 (2/2)

Exercise 11 (1/2)

Exercise 11 (2/2)

Exercise 12 (1/2)

Exercise 12 (2/2)

Exercise 13

Exercise 14

From Class Diagram to ER

From Class Diagram to ER

Identify Classes & Associations
These are the abstract or physical “things” in our system which we wish to describe. Find all the nouns and noun phrases in the domain descriptions you have obtained through your analysis. Consider these class candidates. The class candidates are departments, professor, course, and course section.

From Class Diagram to ER

From Class Diagram to ER

From ER to DB Schema

From ER to DB Schema


Creative Commons Licence
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.