├── .DS_Store ├── Netflix_db_ER.png ├── Queries_and_Graphs ├── .DS_Store ├── Revenue_per_plan.png ├── Trends_of_streams.png ├── netflix_db_schema.png ├── revenue_generated.png ├── content_acquisition.png ├── Average_rating_of_streams.png ├── revenue_per_plan_and_country.png ├── content_popularity_per_country.png └── how_customer_ratings_change_overtime.png ├── README.md └── Netflix_db_queries.sql /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/.DS_Store -------------------------------------------------------------------------------- /Netflix_db_ER.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Netflix_db_ER.png -------------------------------------------------------------------------------- /Queries_and_Graphs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/.DS_Store -------------------------------------------------------------------------------- /Queries_and_Graphs/Revenue_per_plan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/Revenue_per_plan.png -------------------------------------------------------------------------------- /Queries_and_Graphs/Trends_of_streams.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/Trends_of_streams.png -------------------------------------------------------------------------------- /Queries_and_Graphs/netflix_db_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/netflix_db_schema.png -------------------------------------------------------------------------------- /Queries_and_Graphs/revenue_generated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/revenue_generated.png -------------------------------------------------------------------------------- /Queries_and_Graphs/content_acquisition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/content_acquisition.png -------------------------------------------------------------------------------- /Queries_and_Graphs/Average_rating_of_streams.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/Average_rating_of_streams.png -------------------------------------------------------------------------------- /Queries_and_Graphs/revenue_per_plan_and_country.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/revenue_per_plan_and_country.png -------------------------------------------------------------------------------- /Queries_and_Graphs/content_popularity_per_country.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/content_popularity_per_country.png -------------------------------------------------------------------------------- /Queries_and_Graphs/how_customer_ratings_change_overtime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ashleshk/graduate-Database-Organization/main/Queries_and_Graphs/how_customer_ratings_change_overtime.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Database Organization: 2 | # Netflix Media Database Application 3 | The objective of this project is to analyze the customer database & help Netflix make business decisions and recommendations. 4 | 5 | ### Dataset 6 | 7 | The Netflix database was generated using Mockaroo tool to include Customer details, Invoice details, Content, Stream details. The dataset consists of 500 customers across United States, Germany and Australia who have made 1000 transactions with their invoice based on available 3 plans: Basic, Standard and Premium. Content and Stream has 500 instances each. 8 | 9 | ### Database Queries 10 | 11 | This project follows 2nd Normalization form and the ER diagram was developed using MySQL workbench to show the relationship between the 4 entities. Oracle Live SQL was used to develop the following queries to understand the customer database and their interaction with Netflix content data: 12 | 13 | ### 1. How Customer ratings changed overtime ? 14 | 15 | ![Customer rating](https://github.com/Ashleshk/graduate-Database-Organization/blob/main/Queries_and_Graphs/how_customer_ratings_change_overtime.png) 16 | 17 | 18 | ### 2. To determine worth of content acquisition, average rating of each content and trends of content to help Netflix discontinue contents not being watched by its user base 19 | 20 | ![Content Acquistion](https://github.com/Ashleshk/graduate-Database-Organization/blob/main/Queries_and_Graphs/content_acquisition.png) 21 | 22 | 23 | ### 3. To determine the total revenue generated by the customer base in specific country per plan 24 | 25 | ![revenue generated by country/plan](https://github.com/Ashleshk/graduate-Database-Organization/blob/main/Queries_and_Graphs/revenue_generated.png) 26 | 27 | ### 4. What were average rating of streams? 28 | 29 | ![average rating](https://github.com/Ashleshk/graduate-Database-Organization/blob/main/Queries_and_Graphs/Average_rating_of_streams.png) 30 | 31 | 32 | ### Graphical Representation 33 | 34 | ### 1. Plotting Renenue Per Plan and Country 35 | 36 | ![Renenue Per Plan and Country](https://github.com/Ashleshk/graduate-Database-Organization/blob/main/Queries_and_Graphs/revenue_per_plan_and_country.png) 37 | 38 | ### 2. Revenue Earned Per Plan 39 | 40 | ![revenue per plan](https://github.com/Ashleshk/graduate-Database-Organization/blob/main/Queries_and_Graphs/Revenue_per_plan.png) -------------------------------------------------------------------------------- /Netflix_db_queries.sql: -------------------------------------------------------------------------------- 1 | --Query 1: Customer ratings changed overtime: 2 | --Uses inner join from customer’s details to stream data 3 | --Query gives us an overall picture of the fluctuations in customer ratings 4 | --It also helps in making strategic decisions about the future content depending on the most liked or viewed content by an individual customer 5 | 6 | SELECT C.CUSTOMER_ID, C.FIRST_NAME, C.LAST_NAME, C.EMAIL_ID, 7 | S.STREAM_DATE,S.STREAM_RATING,J.TITLE 8 | FROM CUSTOMER C,STEAMS S.CONTENT J 9 | WHERE C.CUSTOMER_ID = S.CUSTOMER_ID AND S.CONTENT_ID = J.CONTENT_ID 10 | ORDER BY C.CUSTOMER_ID, STREAM_DATE DESC; 11 | 12 | 13 | --Query 2: Trends of Streams 14 | --Uses left outer join between content and streams, to display the trend of streams, details of content and customer details 15 | --Helps Netflix to discontinue content not being watched by its user base 16 | 17 | SELECT C.CONTENT_ID, S.STREAM_ID, S.CUSTOMER_ID, S.STREAM_DATE, 18 | S.STREAM_TIME , C.RELEASE_DATE 19 | FROM CONTENT C LEFT OUTER JOIN STEAMS S ON S.CONTENT_ID = C.CONTENT_ID 20 | ORDER BY S.STREAM_ID DESC; 21 | 22 | 23 | --Query 3: Average Rating of the Content 24 | --Query to display title, episode and the average ratings of each content to analyze the performance of each content in the company’s database 25 | --Helps Netflix to consider which content streaming should be discontinued based on avearge rating 26 | 27 | SELECT C.TITLE,C.EPISODE,ROUND(AVG(S.STREAM_RATING),2) AS AVERAGERATING 28 | FROM CONTENT C,STREAMS S 29 | WHERE C.CONTENT_ID = S.CONTENT_ID 30 | GROUP BY C.TITLE,C.EPISODE 31 | 32 | 33 | --Query 4: Content Acquisition 34 | --Uses right outer join to display the Title, Percentage view, Customer amount and Content cost 35 | --The percentage view gives the percentage of customers viewing a content. The percentage viewis restricted to less than 10% of total customers. 36 | --Customer amount calculated is the total amount Netflix receives from customers watching the content. The content cost is calculated as a product of cost_per_stream and episodes columns. This gives the total amount invested by Netflix to acquire a content 37 | --Help Netflix analyze if the investment on content acquired is worth it by comparing customer amount with content cost 38 | 39 | SELECT C.TITLE,COUNT(CU.CUSTOMER_ID)/100 AS "PERCENTAGE_VIEW", 40 | '$' || SUM(I.TOTAL_AMOUNT) AS CUSTOMER_AMOUNT, 41 | '$' || C.TOTAL_COST CONTENT_COST 42 | FROM CONTENT C,INVOICE I, CUSTOMER CU RIGHT OUTER JOIN STREAMS S ON 43 | S.CUSTOMER_ID = CU.CUSTOMER_ID 44 | WHERE C.CONTENT_ID = S.CONTENT_ID AND I.CUSTOMER_ID = CU.CUSTOMER_ID 45 | GROUP BY C.TITLE,C.TOTAL_COST 46 | HAVING COUNT(CU.CUSTOMER_ID)/100 < 0.1 47 | ORDER BY "PERCENTAGE_VIEW" DESC; 48 | 49 | 50 | --Query 5: Annual revenue earned by Netflix based on country and plan 51 | --Query shows the total number of customers in different countries subscribed to different plan. It also gives the annual revenue of Netflix from its customers based on each plan 52 | --Helps Netflix understand which plan is most popular in which country and the total revenue generated 53 | 54 | SELECT COUNTRY, 55 | COUNT(BASIC_PLAN) AS BASIC_PLAN, 56 | COUNT(PREMIUM_PLAN) AS PREMIUM_PLAN, 57 | COUNT(STANDARD_PLAN) AS STANDARD_PLAN, 58 | '$' || SUM(BASIC_PLAN1) * 12 AS BASIC_YEARLY, 59 | '$' || SUM(STANDARD_PLAN1) * 12 AS STANDARD_YEARLY, 60 | '$' || SUM(PREMIUM_PLAN1) * 12 AS PREMIUM_YEARLY 61 | FROM 62 | (SELECT 63 | COUNTRY AS COUNTRY, 64 | CASE WHEN PLAN = 'BASIC' THEN 1 END AS BASIC_PLAN, 65 | CASE WHEN PLAN = 'PREMIUM' THEN 1 END AS PREMIUM_PLAN, 66 | CASE WHEN PLAN = 'STANDARD' THEN 1 END AS STANDARD_PLAN, 67 | DECODE(PLAN,'BASIC',TOTAL_AMOUNT) AS BASIC_PLAN1, 68 | DECODE(PLAN,'PREMIUM',TOTAL_AMOUNT) AS PREMIUM_PLAN1, 69 | DECODE(PLAN,'STANDARD',TOTAL_AMOUNT) AS STANDARD_PLAN1 70 | FROM CUSTOMER JOIN INVOICE USING(CUSTOMER_ID) 71 | WHERE CUSTOMER_ID IN (SELECT DISTINCT(CUSTOMER_ID) FROM INVOICE)) 72 | GROUP BY COUNTRY; 73 | 74 | 75 | --Query 6: Content Popularity 76 | --Query displays movie or show title available in each country and the number of streams 77 | --Helps Netflix understand which content they need to keep to satisfy their customers 78 | --Location was taken into consideration as specific content may be popular in certain countries but not in others 79 | 80 | SELECT C.COUNTRY, T.TITLE, COUNT(S.STREAM_ID) AS "VIEWS FOR EACH CONTENT FOR EACH COUNTRY" 81 | FROM STREAMS S, CUSTOMER C, CONTENT T 82 | WHERE C.CUSTOMER_ID = S.CUSTOMER_ID AND T.CONTENT_ID = S.CONTENT_ID 83 | GROUP BY C.COUNTRY, S.CONTENT_ID, T.TITLE 84 | ORDER BY C.COUNTRY, COUNT(S.STREAM_ID) DESC; 85 | --------------------------------------------------------------------------------