Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. -- View: "viewMovies"
  2.  
  3. -- DROP VIEW "viewMovies";
  4.  
  5. CREATE OR REPLACE VIEW "viewMovies" AS
  6. SELECT "Movies"."Name", "Movies"."Year", "Genres"."Type" AS "Genre", "Formats"."FormatTitle" AS "Format", "Ratings"."RatingTitle" AS "Rating", "Directors"."FirstName" AS "Director FirstName", "Directors"."LastName" AS "Directors LastName", "Actors"."FirstName" AS "Actor FirstName", "Actors"."LastName" AS "Actor LastName", "Comments"."UserComments", "Languages"."Language", "Movies"."PersonalRating"
  7. FROM "Movies"
  8. LEFT JOIN "Genres" ON "Movies"."GenreId" = "Genres"."Id"
  9. LEFT JOIN "Formats" ON "Movies"."FormatId" = "Formats"."Id"
  10. LEFT JOIN "Ratings" ON "Movies"."RatingId" = "Ratings"."Id"
  11. LEFT JOIN "Directors" ON "Movies"."DirectorId" = "Directors"."Id"
  12. LEFT JOIN "Comments" ON "Movies"."CommentsId" = "Comments"."Id"
  13. LEFT JOIN "Languages" ON "Movies"."LanguagesId" = "Languages"."Id"
  14. LEFT JOIN "Actors" ON "Movies"."ActorId1" = "Actors"."Id" OR "Movies"."ActorId2" = "Actors"."Id" OR "Movies"."ActorId3" = "Actors"."Id";
  15.  
  16. ALTER TABLE "viewMovies" OWNER TO postgres;
  17. COMMENT ON VIEW "viewMovies" IS 'Will return all data for a movie by joining all tables in our database';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement