From 8ec63d6b0df2ee492a748a3c3abe3bd0ea192c61 Mon Sep 17 00:00:00 2001 From: Alexander Sergeev Date: Sun, 3 Dec 2023 22:27:48 +0300 Subject: [PATCH 1/2] Update README.md --- README.md | 79 +++++++++++++------------------------------------------ 1 file changed, 18 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index d359a0d..f758fcb 100644 --- a/README.md +++ b/README.md @@ -1,91 +1,48 @@ # java-filmorate Template repository for Filmorate project. -![filmorate ER diagram](https://github.com/sergeev-alexander/java-filmorate/assets/131286043/143683b3-4936-420f-9083-0368b108f0f6) - +![filmorate_er_diagram](https://github.com/sergeev-alexander/java-filmorate/assets/131286043/bf1037cb-e730-4839-a883-6f735de7e089) -- SOME QUERRY EXAMPLES -- ``` + -- get film by SELECT * FROM films -WHERE films.film_id = ; +WHERE film_id = ; --- get film genre names by - -SELECT genres.name -FROM films -INNER JOIN film_genres USING (film_id) -INNER JOIN genres USING (genre_id) -WHERE films.film_id = ; - - --- get films by +-- get film genres by SELECT * -FROM films -INNER JOIN film_genre USING (film_id) -INNER JOIN genres USING (genre_id) -WHERE genres.name = ''; +FROM genres +INNER JOIN film_genres USING (genre_id) +INNER JOIN films USING (film_id) +WHERE films.film_id = ; --- get films by +-- get mpa by SELECT * -FROM films -INNER JOIN mpa_ratings USING (mpa_id) -WHERE mpa.name = ''; +FROM mpa_ratings +INNER JOIN films USING (mpa_id) +WHERE films.film_id = ''; --- get likes quantity +-- get rates by -SELECT COUNT(likes.film_id) -FROM likes -WHERE likes.film_id = ; +SELECT user_id +FROM rates +WHERE film_id = ; ---get users liked +--get users friends by SELECT * FROM users -INNER JOIN likes USING (film_id) -WHERE likes.film_id = ; - - --- get liked films by - -SELECT * -FROM films -INNER JOIN likes USING (user_id) +INNER JOIN frienships USING (user_id) WHERE user_id = ; - - --- get friends in status --- friendship_statuses contains {1 = send_offer, 2 = received_offer, 3 = friends} - -SELECT * -FROM users -INNER JOIN friendships USING (user_id) -INNER JOIN friendship_statuses USING (friendship_status_id) -WHERE friendships.user_id = - AND frendship_statuses.name = ''; - - --- get NOT friends - -SELECT * -FROM users -WHERE users.user_id NOT IN (SELECT friend_id - FROM friendships - WHERE friendships.user_id = ); - - --- get friends quantity in status --- friendship_statuses contains {1 = send_offer, 2 = received_offer, 3 = friends} - -SELECT COUNT(*) FROM users INNER JOIN friendships USING (user_id) INNER JOIN friendship_statuses USING (friendship_status_id) From 3cf27dff28c5072141e705e0bed4f973cce1a8fd Mon Sep 17 00:00:00 2001 From: Alexander Sergeev Date: Sun, 3 Dec 2023 22:28:37 +0300 Subject: [PATCH 2/2] Update README.md --- README.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/README.md b/README.md index f758fcb..c747d39 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,4 @@ SELECT user_id FROM rates WHERE film_id = ; - ---get users friends by - -SELECT * -FROM users -INNER JOIN frienships USING (user_id) -WHERE user_id = ; -FROM users -INNER JOIN friendships USING (user_id) -INNER JOIN friendship_statuses USING (friendship_status_id) -WHERE friendships.user_id = - AND frendship_statuses.name = ''; ```