Based on the SQLD exam syllabusReport an error
If the name "SMITH" appears twice in an employee table, you cannot decide which SMITH's salary to change. That is why every entity needs a label that can pinpoint a single row. That label is the identifier.
EMPNO is the primary identifier. ENAME does not repeat in the current data, but business rules cannot prevent two employees from having the same name.Counting the overlapping values in EMP of the SCOTT schema gives the following.
SELECT COUNT(*) AS CNT, COUNT(DISTINCT EMPNO) AS EMPNO_CNT,
COUNT(DISTINCT ENAME) AS ENAME_CNT, COUNT(DISTINCT JOB) AS JOB_CNT
FROM EMP; CNT EMPNO_CNT ENAME_CNT JOB_CNT
---------- ---------- ---------- ----------
14 14 14 5JOB has only 5 distinct values across 14 rows, so it cannot be an identifier.ENAME is also not repeated right now, with 14 distinct values. But being unique in the current data by chance is different from being unique by business rule. Choose identifiers by the latter.| Characteristic | Meaning | Example from EMP |
|---|---|---|
| Uniqueness | The primary identifier uniquely distinguishes every instance in the entity | Two employees cannot have the same EMPNO |
| Minimality | The number of attributes in the primary identifier is the minimum needed to keep it unique | EMPNO alone is enough, so (EMPNO, ENAME) violates minimality |
| Immutability | Once set, the primary identifier value should not change often | The employee number stays the same even when the employee moves departments |
| Existence | A primary identifier value must always exist (NULL not allowed) | You cannot create an employee row without an employee number |
(order number, product number) to be unique, then two is the minimum.⚠️ Trap: A choice saying "names don't overlap right now, so uniqueness is satisfied" is wrong. Uniqueness must be guaranteed by business rules. Also, "a primary identifier must be a single attribute" is a wrong statement. A composite primary identifier can satisfy minimality too.
When there are several candidates, pick one using these criteria.
The same identifier gets four different names depending on the criterion. You need to remember each criterion together with its pair of types to tell the answer choices apart.
| Classification criterion | Type | Meaning |
|---|---|---|
| Representativeness | Primary identifier | Represents the entity and can form reference relationships with other entities |
| Secondary identifier (alternate identifier) | Can distinguish instances but lacks representativeness, so it is not used to connect reference relationships | |
| Origin | Internal identifier | An identifier created on its own inside the entity |
| Foreign identifier | An identifier received through a relationship with another entity | |
| Number of attributes | Single identifier | Made up of one attribute |
| Composite identifier | Made up of two or more attributes | |
| Substitution | Natural identifier | An identifier created by the business itself |
| Surrogate identifier | An identifier that does not exist in the business but is created artificially (a serial number, etc.) |
Applying this to EMP and DEPT gives the following.
| Attribute | Classification |
|---|---|
EMP.EMPNO | Primary identifier · internal identifier · single identifier · natural identifier |
EMP.DEPTNO | A foreign identifier received from DEPT through the relationship (the FK in the physical model) |
| A national ID number placed in the employee entity | A secondary identifier: it can distinguish employees but is not used as the representative |
(order number, product number) of an order line item | Composite identifier |
EMP.DEPTNO is a foreign identifier, but it is not part of EMP's primary identifier.The parent entity's primary identifier travels down to the child through the relationship. The name of the relationship depends on what role the attribute that came down plays inside the child.
[Identifying relationship] [Non-identifying relationship]
Order Order Item DEPT EMP
┌──────────┐ ┌────────────┐ ┌──────────┐ ┌──────────┐
│ OrderNo PK│──────<│ OrderNo PK│ │ DEPTNO PK│- - -<│ EMPNO PK│
│ OrderDate │ │ ProductNoPK│ │ DNAME │ │ ENAME │
└──────────┘ │ Quantity │ └──────────┘ │ DEPTNO FK│
└────────────┘ └──────────┘
Parent PK is part of the child PK Parent PK is a regular child attribute
(IE notation: solid line) (IE notation: dotted line)| Comparison | Identifying relationship | Non-identifying relationship |
|---|---|---|
| Position of the parent PK | Part of the child's primary identifier | A regular attribute of the child |
| Existence of the child | Cannot exist without the parent | Can exist without the parent (when the relationship is optional) |
| Connection strength | Strong connection | Weak connection |
| IE notation | Solid line | Dotted line |
| Example | Order → Order Item | DEPT → EMP |
EMP.DEPTNO must allow NULL.In the following situations, consider a non-identifying relationship instead of an identifying one.
| Choice | Problem |
|---|---|
| Connect with identifying relationships only | The child's primary identifier attributes keep growing at each level down. Join conditions get longer and SQL gets more complicated |
| Connect with non-identifying relationships only | When a grandchild entity needs the grandparent's value, you must join multiple times through the intermediate entities |
For example, if you connect Customer → Order → Order Item → Shipment entirely with identifying relationships, the primary identifier of Shipment becomes (customer number, order number, product number, shipment sequence). Conversely, if you connect them all as non-identifying, you must join Order Item and Order in turn just to see the customer name from Shipment.
You can also see in the actual data that DEPTNO in EMP is a foreign identifier received through a non-identifying relationship.
SELECT EMPNO, ENAME, JOB, MGR, DEPTNO FROM EMP WHERE DEPTNO = 10 ORDER BY EMPNO; EMPNO ENAME JOB MGR DEPTNO
---------- ---------- --------- ---------- ----------
7782 CLARK MANAGER 7839 10
7839 KING PRESIDENT 10
7934 MILLER CLERK 7782 10EMPNO alone distinguishes each row. DEPTNO is a regular attribute that is not part of the key.MGR is also a foreign identifier received from EMP's own EMPNO. An employee with no higher-level manager, like KING, has NULL. We will revisit this self-referencing relationship on Day 4.💡 Summary table: Identifying relationship = the parent PK goes into the child PK; non-identifying relationship = the parent PK goes into a regular child column. If you ask "can the child exist without the parent?", the answer points to the non-identifying relationship.
Tomorrow we cover normalization, which splits entities based on functional dependency.
Click a choice to reveal the answer and explanation.
Question 1
Which of the following is NOT a characteristic of a primary identifier?
Question 2
The primary identifier of the employee entity was set as (employee number, employee name). If the employee number alone uniquely distinguishes every employee, which characteristic of a primary identifier is violated?
Question 3
Which of the following pairs of identifiers with their classification criteria is NOT correct?
Question 4
Which relationship best fits the following description? > The parent entity's primary identifier is inherited as a regular attribute of the child entity, and the child entity can be created even without the parent.
Question 5
Which of the following best describes what happens when Customer → Order → Order Item → Shipment are all connected using identifying relationships only?