├── README.md
└── ex00
└── my_allocine.rb
/README.md:
--------------------------------------------------------------------------------
1 | # Welcome to My Allocine
2 | ***
3 |
4 | ## Task
5 | gaergergfdgvsrsgsrgdgergfergeggg
6 |
7 | ## Description
8 | ehfwehfijafpokje9qwdr9qur89uqr98qty89tt
9 |
10 | ## Installation
11 | eeheuifhuhfhiwehfhwefuewuewufgegeg
12 |
13 | ## Usage
14 | weiufuweifwenfiuhweufhiwehfiuwefuuifgugfugu
15 | ```
16 | ./my_project argument1 argument2
17 | ```
18 |
19 | ### The Core Team
20 |
21 |
22 | Made at Qwasar Silicon Valley
23 |
24 |
--------------------------------------------------------------------------------
/ex00/my_allocine.rb:
--------------------------------------------------------------------------------
1 | requests['Display all actors'] = "SELECT * FROM actors;"
2 | requests['Display all genres'] = "SELECT * FROM genres;"
3 | requests['Display the name and year of the movies'] = "SELECT mov_title, mov_year FROM movies;"
4 | requests['Display reviewer name from the reviews table'] = "SELECT rev_name FROM reviews;"
5 | requests["Find the year when the movie American Beauty released"] = "
6 | SELECT
7 | mov_year
8 | FROM
9 | movies
10 | WHERE
11 | mov_title = 'American Beauty';
12 | "
13 | requests["Find the movie which was released in the year 1999"] = "
14 | SELECT
15 | mov_title
16 | FROM
17 | movies
18 | WHERE
19 | mov_year = 1999;
20 | "
21 | requests["Find the movie which was released before 1998"] = "
22 | SELECT
23 | mov_title
24 | FROM
25 | movies
26 | WHERE
27 | mov_year < 1998;
28 | "
29 | requests["Find the name of all reviewers who have rated 7 or more stars to their rating order by reviews rev_name (it might have duplicated names :-))"] = "
30 | SELECT
31 | rev_name
32 | FROM
33 | reviews
34 | JOIN
35 | movies_ratings_reviews ON reviews.id = movies_ratings_reviews.rev_id
36 | WHERE
37 | rev_stars >= 7
38 | ORDER BY
39 | rev_name;
40 | "
41 | requests["Find the titles of the movies with ID 905, 907, 917"] = "
42 | SELECT
43 | mov_title
44 | FROM
45 | movies
46 | WHERE
47 | id IN (905, 907, 917);
48 | "
49 | requests["Find the list of those movies with year and ID which include the words Boogie Nights"] = "
50 | SELECT
51 | id, mov_title, mov_year
52 | FROM
53 | movies
54 | WHERE
55 | mov_title LIKE '%Boogie Nights%';
56 | "
57 | requests["Find the ID number for the actor whose first name is 'Woody' and the last name is 'Allen'"] = "
58 | SELECT
59 | id
60 | FROM
61 | actors
62 | WHERE
63 | act_fname = 'Woody' AND act_lname = 'Allen';
64 | "
65 |
66 | requests["Find the actors with all information who played a role in the movies 'Annie Hall'"] = "
67 | SELECT
68 | DISTINCT actors.*
69 | FROM
70 | movies
71 | JOIN
72 | movies_actors ON
73 | mov_id = (
74 | SELECT
75 | id
76 | FROM
77 | movies
78 | WHERE
79 | mov_title = 'Annie Hall'
80 | )
81 | JOIN
82 | actors ON act_id = actors.id;
83 | "
84 | requests["Find the first and last names of all the actors who were cast in the movies 'Annie Hall', and the roles they played in that production"] = "
85 | SELECT
86 | act_fname, act_lname, role
87 | FROM
88 | movies
89 | JOIN
90 | movies_actors ON mov_id = movies.id
91 | JOIN
92 | actors ON act_id = actors.id
93 | WHERE
94 | mov_title = 'Annie Hall';
95 | "
96 |
97 | requests["Find the name of movie and director who directed a movies that casted a role as Sean Maguire"] = "
98 | SELECT
99 | dir_fname, dir_lname, mov_title
100 | FROM
101 | movies_actors
102 | JOIN
103 | movies ON movies.id = movies_actors.mov_id
104 | JOIN
105 | directors_movies ON movies.id = directors_movies.mov_id
106 | JOIN
107 | directors ON directors_movies.dir_id = directors.id
108 | WHERE
109 | role = 'Sean Maguire';
110 | "
111 |
112 | # Hmm, what about actors who have never acted in a movie?
113 | requests["Find all the actors who have not acted in any movie between 1990 and 2000 (select only actor first name, last name, movie title and release year)"] = "
114 | SELECT
115 | DISTINCT act_fname, act_lname, mov_title, mov_year
116 | FROM
117 | actors
118 | JOIN movies_actors ON actors.id = movies_actors.act_id
119 | JOIN
120 | movies ON movies_actors.mov_id = movies.id
121 | WHERE
122 | mov_year NOT BETWEEN 1990 AND 2000;
123 | "
--------------------------------------------------------------------------------