Two rows, one key: a study record needs more than a date

A table can contain two perfectly valid rows with the same date. Before calling one a duplicate, ask what each row represents. This workshop uses a small reading log to show why a date may be a useful label without being a unique identifier.

Every record below is fictional. The example is about organizing information, not real people, course results or financial performance.

Define the unit of a row

Suppose each row records one study session for one card. The fields are session code, day, card code and reading minutes. A session code identifies a particular session, not a card or a day.

The first row is session S1, day 1, card A, 10 minutes. The second is session S2, day 1, card B, 15 minutes. The third is session S3, day 2, card A, 12 minutes. These are three different sessions.

The day repeats, and the card code repeats, but neither repetition is an error. Two cards can be studied on the same day, and the same card can be studied on different days.

Check a proposed key

A key is a field, or group of fields, whose values distinguish rows according to the table's rules. If we propose the day alone as the key, the first two rows expose the problem: both have day 1.

If we propose card code alone, S1 and S3 both contain A. That also fails. In this small table, session codes S1, S2 and S3 are distinct, so the session code passes the uniqueness check.

Passing one table does not establish a permanent rule. The system must also assign a different code to every new session and preserve that code when the same session is corrected.

Try a pair of fields

The day and card code together are distinct in our three rows: day 1 with A, day 1 with B, and day 2 with A. It is tempting to use this pair instead of a session code.

Now add S4: day 1, card A, 8 minutes. This represents another session on the same day, not a copy of S1. The pair day 1 and A is no longer unique.

A pair that happens to be unique in a sample is not necessarily a valid key for the process. We must ask whether the process permits two sessions for the same card on the same day. Here it does.

Keep corrections separate from new sessions

Suppose the reading time for S1 was entered incorrectly and should be 11 minutes. Changing that value does not create a new session. The identifier remains S1, while the recorded minutes change from 10 to 11.

A new session, by contrast, receives a new code even if its day, card and duration happen to match an earlier session. Equal descriptive values do not prove that two records describe the same event.

Do not invent a deletion rule

Finding a repeated session code is a reason to investigate. It might be an accidental copy, a second version of a correction or a mistake in code assignment. The key check identifies a conflict; it does not decide which row should disappear.

Keep the original records available while checking the source and the update rule. Removing a row simply because its day repeats would erase valid sessions from this example.

A check to write beside the table

State what one row represents. Name the proposed key and check for repeated values. Then ask whether a valid future event could reuse that key. Keep identifiers stable during corrections, and separate uniqueness checks from decisions about deleting records.

Academia Master Trader is a Brazilian educational project. Domain: academiamastertrader.com.br. Keep learning on Aprenda: https://academiamastertrader.com.br/materiais/aprenda/