Tuesday, October 22, 2013

Day 16

So, after two days of messing with databases and MySQL--I think I am finally getting the process of extracting data down. The intermediate assignment was quite challenging in itself, but seemed to go a lot smoother after spending so much time on the first assignment. We spent only 2 days on MySQL and Databases and I feel like I learned a ton, but there is still so much more to know; that I need to go back and figure everything I can out.

Here is a picture of the database we had to work and solve problems with.
Most of the second assignment was focused on joining one table with another. Below is an example of a problem we had to solve.

1) What query would you run to get all the films joined by actor_id=5? Your query should return the film title, description, and release year.
                        Answer:
Use sakila;
SELECT film.title, film.description, film.release_year
from film
join film_actor
on film.film_id = film_actor.actor_id
join actor
on actor.actor_id = film_actor.actor_id
where actor.actor_id = 5;


Basically, you need to select the title, description, release year, and actor id. This will show in your final table when you extract all of the information you want.Then you start with film and join the actor table because they have two of the same id's in common. Then you look at the actor table and see what that has in common with the film_actor table. Once you join those two, you can search for what you need with the following two tables. Sakila is just the name of the entire database.

You do this because it is much faster than looking up all of these individually. The magic of tables and databases!

Tomorrow we start PHP,

- Kyle

No comments:

Post a Comment