Create a Simple SQL View
📖 Scenario: You work at a bookstore that keeps track of books and their authors in a database. You want to create a simple view to easily see the book titles along with their authors' names.
🎯 Goal: Build a SQL view named BookAuthorView that shows the title of each book and the author_name from the existing tables.
📋 What You'll Learn
Create a table called
Books with columns book_id (integer), title (text), and author_id (integer).Create a table called
Authors with columns author_id (integer) and author_name (text).Insert the exact data into
Books: (1, 'The Great Gatsby', 101), (2, '1984', 102), (3, 'To Kill a Mockingbird', 103).Insert the exact data into
Authors: (101, 'F. Scott Fitzgerald'), (102, 'George Orwell'), (103, 'Harper Lee').Create a view named
BookAuthorView that shows title and author_name by joining Books and Authors on author_id.💡 Why This Matters
🌍 Real World
Views help simplify complex queries by creating a virtual table that users can query easily without writing joins every time.
💼 Career
Database developers and analysts often create views to provide clean, reusable data access layers for applications and reports.
Progress0 / 4 steps