Course contentsShow
← Databases & SQL
Lesson 19 of 1,9531. Relational FoundationsFree lesson

Projection and Aliasing

Select only necessary columns and provide intuitive labels for readability and integration.

In this lesson, you will learn how to refine your query results by selecting only the specific data you need and giving that data meaningful, readable labels.

The Power of Projection

Up until now, you have likely been selecting entire rows from your tables using SELECT *. However, in professional database work, we rarely need every single attribute. Projection is the process of choosing only the specific columns you want to see.

Think of projection like using a camera lens to zoom in on a specific subject. By narrowing your focus to only the relevant attributes, you reduce the amount of data the database has to transmit, which makes your applications faster and your output much cleaner.

Using Aliases for Clarity

Sometimes, the names of columns in a database aren't very "human-friendly." For example, you might have a column named cust_email_addr_01. If you want your report to look professional, you don’t want that messy technical name staring back at the user.

Aliasing allows you to rename a column in your output. It doesn’t change the actual name in the database table—it just creates a temporary "nickname" for the result set. We use the AS keyword to accomplish this.

Practical Example

Imagine we have a employees table. Instead of pulling everything, we only want the name and the salary. We also want the labels to be easy to read:

SELECT 
    full_name AS Name, 
    annual_salary AS Salary
FROM employees;

In this query:

  1. Projection: We restricted the output to only the full_name and annual_salary columns.
  2. Aliasing: We used AS Name and AS Salary to transform those technical headers into clean, presentation-ready labels.

By combining these two techniques, you ensure that your queries return exactly what is required—and nothing more—while ensuring the presentation is clear for whoever is reading the results.

Key Takeaway: Projection allows you to isolate specific columns to minimize data overhead, while aliasing transforms technical column headers into clear, readable labels for your final output.