Information & AI guides →

Information & AI · Workplace data and databases

Workplace data: identify rows, connect tables and group changes

Edited by: Hitoiki Arcade / Hitoiki Learning team · Published: · References and presentation updated: · Editorial policy

When customer and order tables are connected, how should identical names or customers with no orders be handled? Database terms help make those business conditions explicit. Start with row identity, then matching related rows, and finally grouping changes that must succeed together.

The guide introduces relational databases and standard SQL. Some details, including null handling, vary across products and configurations, so read the examples' premises. Displaying a table and correctly representing its customers or transactions are separate achievements.

Identify a row without relying on its display name

A customer row groups information about one customer; its columns hold item types such as an address. A standard SQL primary key uniquely identifies a row and has non-null values. Shared names and name changes illustrate why a person's name alone is often a poor identifier.

A stable customer ID referenced by orders separates display-name changes from identity. Repeating the same fact manually across many rows can create contradictions after partial updates. Deciding which table owns which subject's facts provides a foundation for reliable relationships.

SQL means Structured Query Language, used to retrieve and modify table data. A query asks for data. Distinguishing which row a key identifies from which rows a query selects connects storage rules with operations without treating them as the same mechanism.

Try a quiz on Workplace data and databases

Each section link opens a quiz on related topics. Questions may cover more than that section, so check the range and difficulty before starting.

Decide what survives a join

An INNER JOIN returns matching row combinations. Joining customers to orders this way leaves customers with no orders out of the result. A LEFT JOIN preserves the left-side customers and supplies nulls in the right-side columns when an order match is absent.

Do not silently treat a null as zero sales or an empty string. How an absent match should be reported depends on the query's purpose. Joins can also expand row counts, so the number of result rows need not equal the number of customers originally selected.

Make related updates one unit of completion

Recording a transfer can involve reducing one balance and increasing another. Transaction atomicity makes grouped changes all-or-nothing. It prevents the intended operation from taking effect only in part, such as recording one side of a transfer without the other.

COMMIT finalizes a transaction; ROLLBACK cancels uncommitted changes. Completion, visibility to other work and recovery after media loss concern different guarantees. One success message should not be treated as evidence that every possible requirement has been met.

Decide what is being counted before aggregating

With three scores 10, NULL and 20, COUNT(*) counts three rows while COUNT(score) counts two non-null values. Numeric zero is a present value rather than the same thing as missing information. To find nulls, use IS NULL; an ordinary equality comparison involving NULL produces unknown. Keep missing values, zero values and record counts distinct.

WHERE selects original rows before aggregation, and HAVING selects groups after aggregation. Keeping positive sales before department totals differs from totaling all sales and then retaining positive totals, because negative rows enter only the latter calculation. Write the processing stages as row condition, group calculation and group condition to identify what each filter affects.

Rows and present values are different

Rows and present values are differentAn invented four-row table has two NULL cells. Left-side guides refer to every row; right-side guides refer to non-NULL values. No aggregate answer is displayed; the sketch distinguishes what is counted.RowValue————ANULLBNULLAll rowsNon-NULL
NULL differs from a value of zero. Counting rows and counting non-NULL values are separate operations.

Identification and search structures require maintenance

A composite primary key using order number and line number requires uniqueness of the pair, not each column separately. Order 1 can have lines 1 and 2. A foreign key constrains a reference to a matching key, such as linking an order’s customer ID to an existing customer. Display labels, row identity and references between rows have different jobs.

An index adds a structure for locating relevant rows, rather like a book’s index points to useful pages. Table changes also require keeping the index consistent, adding storage and write work. Do not add indexes without limit based only on search speed. Choose them by comparing frequently used queries with modification frequency and maintenance costs.

TRY & READ

Check your understanding with examples

Compare the choices before opening the answer and explanation. Reading an example does not save a test answer or score.

Example 1 · Workplace data and databases

What are basic requirements of a primary key in a standard SQL table?

  1. Unique but nullable
  2. Non-null but allows duplicates
  3. Automatically renumber every row
  4. Uniquely identify each row and contain no nulls
Read the answer and explanation

Answer: Uniquely identify each row and contain no nulls

A primary key identifies a row and requires both uniqueness and non-null values. Duplicate keys make the reference ambiguous, while a null key supplies no identifying value. Names can collide or change, so a display name should not automatically become the key.

Read reasoning and more detail

Separate the label shown to people from the identifier used to distinguish and reference the row. SQL means Structured Query Language, used to retrieve and modify table data. A query asks for data; that operation differs from the primary-key rule identifying stored rows.

Sources for this example

  • PostgreSQL — Constraints

    NOT NULL, UNIQUE, primary keys, foreign keys and deletion actions.

    Source checked: 2026-10-05
  • MDN Web Docs — SQL

    SQL's full name and retrieving, updating and calculating table data.

    Source checked: 2026-10-05

Example 2 · Workplace data and databases

What happens in a LEFT JOIN when a left-side row has no right-side match?

  1. Fill right-side columns with zeros
  2. Match the unmatched left row to every right row
  3. Keep the left row with nulls for right-side columns
  4. Remove the unmatched left row
Read the answer and explanation

Answer: Keep the left row with nulls for right-side columns

A LEFT JOIN preserves left-side rows and supplies nulls for right-side columns when no match exists. Joining all customers to orders can therefore retain a customer who has placed no order. Those nulls indicate missing matched values, not deletion of the customer row.

Read reasoning and more detail

The key contrast with an INNER JOIN is whether an unmatched left-side row remains in the result.

Sources for this example

Example 3 · Workplace data and databases

What does database transaction atomicity mean?

  1. Define allowed conditions for related values
  2. Grouped changes take effect together or not at all
  3. Committed changes survive restart
  4. Isolate intermediate concurrent changes
Read the answer and explanation

Answer: Grouped changes take effect together or not at all

Atomicity makes a group of operations all-or-nothing. A transaction bundles related steps into that unit, which matters when updating only one of two related values would leave an inconsistent result. If completion fails, partial effects must not remain as the final outcome.

Read reasoning and more detail

Merely executing several statements in sequence is different from obtaining the transaction’s all-or-nothing property.

Sources for this example

Sources for this guide

Continue with a quiz

Topics: Workplace data and databases. Range: Everyday knowledge, Broader knowledge, General knowledge. Difficulty: Basic, Standard. These are selected initially. You can change these on the setup screen.

Try this topic in a quiz

This opens the setup screen with this subject and topic selected. Check the mode and question count before you start.

A test shows explanations after submission. Continuous challenge explains each answer. Review uses unresolved mistakes recorded on this device. Casual mode does not update learning records.

Enjoyed it? Share the link

Only the page address is shared. Your saves and results are not included.

Link to this page