You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Table storing all customers. Holds foreign keys to the address table and the store table where this customer is registered.
Basic information about the customer like first and last name are stored in the table itself. Same for the date the record was created and when the information was last updated.
---- View structure for view `actor_info`--
CREATE DEFINER=CURRENT_USER SQL SECURITY INVOKER VIEW actor_info
ASSELECTa.actor_id,
a.first_name,
a.last_name,
GROUP_CONCAT(DISTINCT CONCAT(c.name, ': ',
(SELECT GROUP_CONCAT(f.titleORDER BYf.title SEPARATOR ', ')
FROMsakila.film f
INNER JOINsakila.film_category fc
ONf.film_id=fc.film_idINNER JOINsakila.film_actor fa
ONf.film_id=fa.film_idWHEREfc.category_id=c.category_idANDfa.actor_id=a.actor_id
)
)
ORDER BYc.name SEPARATOR '; ')
AS film_info
FROMsakila.actor a
LEFT JOINsakila.film_actor fa
ONa.actor_id=fa.actor_idLEFT JOINsakila.film_category fc
ONfa.film_id=fc.film_idLEFT JOINsakila.category c
ONfc.category_id=c.category_idGROUP BYa.actor_id, a.first_name, a.last_name
customer_list
Description:
Sql:
---- View structure for view `customer_list`--CREATEVIEWcustomer_listASSELECTcu.customer_idAS ID, CONCAT(cu.first_name, _utf8'', cu.last_name) AS name, a.addressAS address, a.postal_codeAS`zip code`,
a.phoneAS phone, city.cityAS city, country.countryAS country, IF(cu.active, _utf8'active',_utf8'') AS notes, cu.store_idAS SID
FROM customer AS cu JOIN address AS a ONcu.address_id=a.address_idJOIN city ONa.city_id=city.city_idJOIN country ONcity.country_id=country.country_id
film_list
Description:
Sql:
---- View structure for view `film_list`--CREATEVIEWfilm_listASSELECTfilm.film_idAS FID, film.titleAS title, film.descriptionAS description, category.nameAS category, film.rental_rateAS price,
film.lengthAS length, film.ratingAS rating, GROUP_CONCAT(CONCAT(actor.first_name, _utf8'', actor.last_name) SEPARATOR ', ') AS actors
FROM category LEFT JOIN film_category ONcategory.category_id=film_category.category_idLEFT JOIN film ONfilm_category.film_id=film.film_idJOIN film_actor ONfilm.film_id=film_actor.film_idJOIN actor ONfilm_actor.actor_id=actor.actor_idGROUP BYfilm.film_id, category.name
sales_by_store
Description:
Sql:
---- View structure for view `sales_by_store`--CREATEVIEWsales_by_storeASSELECT
CONCAT(c.city, _utf8',', cy.country) AS store
, CONCAT(m.first_name, _utf8'', m.last_name) AS manager
, SUM(p.amount) AS total_sales
FROM payment AS p
INNER JOIN rental AS r ONp.rental_id=r.rental_idINNER JOIN inventory AS i ONr.inventory_id=i.inventory_idINNER JOIN store AS s ONi.store_id=s.store_idINNER JOIN address AS a ONs.address_id=a.address_idINNER JOIN city AS c ONa.city_id=c.city_idINNER JOIN country AS cy ONc.country_id=cy.country_idINNER JOIN staff AS m ONs.manager_staff_id=m.staff_idGROUP BYs.store_idORDER BYcy.country, c.city
sales_by_film_category
Description:
Sql:
---- View structure for view `sales_by_film_category`---- Note that total sales will add up to >100% because-- some titles belong to more than 1 category--CREATEVIEWsales_by_film_categoryASSELECTc.nameAS category
, SUM(p.amount) AS total_sales
FROM payment AS p
INNER JOIN rental AS r ONp.rental_id=r.rental_idINNER JOIN inventory AS i ONr.inventory_id=i.inventory_idINNER JOIN film AS f ONi.film_id=f.film_idINNER JOIN film_category AS fc ONf.film_id=fc.film_idINNER JOIN category AS c ONfc.category_id=c.category_idGROUP BYc.nameORDER BY total_sales DESC
staff_list
Description:
Sql:
---- View structure for view `staff_list`--CREATEVIEWstaff_listASSELECTs.staff_idAS ID, CONCAT(s.first_name, _utf8'', s.last_name) AS name, a.addressAS address, a.postal_codeAS`zip code`, a.phoneAS phone,
city.cityAS city, country.countryAS country, s.store_idAS SID
FROM staff AS s JOIN address AS a ONs.address_id=a.address_idJOIN city ONa.city_id=city.city_idJOIN country ONcity.country_id=country.country_id
nicer_but_slower_film_list
Description:
Sql:
---- View structure for view `nicer_but_slower_film_list`--CREATEVIEWnicer_but_slower_film_listASSELECTfilm.film_idAS FID, film.titleAS title, film.descriptionAS description, category.nameAS category, film.rental_rateAS price,
film.lengthAS length, film.ratingAS rating, GROUP_CONCAT(CONCAT(CONCAT(UCASE(SUBSTR(actor.first_name,1,1)),
LCASE(SUBSTR(actor.first_name,2,LENGTH(actor.first_name))),_utf8'',CONCAT(UCASE(SUBSTR(actor.last_name,1,1)),
LCASE(SUBSTR(actor.last_name,2,LENGTH(actor.last_name)))))) SEPARATOR ', ') AS actors
FROM category LEFT JOIN film_category ONcategory.category_id=film_category.category_idLEFT JOIN film ONfilm_category.film_id=film.film_idJOIN film_actor ONfilm.film_id=film_actor.film_idJOIN actor ONfilm_actor.actor_id=actor.actor_idGROUP BYfilm.film_id, category.name