DATABASE
    beginner

    Relational Algebra & Joins

    Software Engineer path · lesson 50 of 99
    Table A
    Table B
    Match
    Users (A)
    IDName
    1Alice
    2Bob
    3Eve
    Orders (B)
    U_IDItem
    1Pen
    2Mug
    9Hat
    Result
    IDNameItem
    1AlicePen
    2BobMug

    σ, π or ⋈?

    Sort

    Sort each description into the relational operator it describes.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    σ Selection

    Drop items here

    π Projection

    Drop items here

    ⋈ Join

    Drop items here
    6 pieces left to place

    Test your knowledge

    21 questions
    Question 1 of 21
    Score: 0

    If Table A has 5 rows and Table B has 4 rows, and you perform a CROSS JOIN (Cartesian Product), how many rows will be in the result set?

    The short version

    Relational Algebra is the blueprint for SQL. Projection is slicing a spreadsheet vertically (keeping only some columns). Selection is slicing it horizontally (keeping only some rows). A Join is stitching two spreadsheets together based on matching IDs.

    In more depth

    Relational Algebra

    The theoretical foundation that powers all relational databases.

    Core Operations

    Selection (σ): Filters rows that meet a condition (SQL WHERE).
    Projection (π): Selects specific columns (SQL SELECT col1, col2).
    Join (⋈): Combines rows from two tables based on a related column.

    Join Types

    Inner Join: Returns only rows with a match in both tables.
    Left Join: Returns all rows from the left table, and matching rows from the right (or NULLs).

    Interview Questions

    Amazon
    Microsoft
    Google
    Amazon
    Microsoft
    Meta
    Netflix
    Uber

    Love this visualization?

    Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.

    100% free • No credit card required