Skip to content
Activities · Activity 9.5

Q.Add foreign key in the ATTENDANCE table (use Figure 9.1) to identify referencing and referenced tables).
The printed textbook cites "Figure 9.1" here, but this chapter's real Figure 9.1 is the MySQL shell screenshot (unrelated) — the diagram this activity actually means is Figure 8.1 from the previous chapter, shown below for reference.

Figure 8.1: Record structure of three files in STUDENTATTENDANCE database
Figure 8.1
Odisha ChseTextbookSubjective· 2mImportance★★★★★est
11% · 10/95 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

ATTENDANCE is the referencing (child) table and STUDENT is the referenced (parent) table, linked through RollNumber. This mirrors exactly how the chapter already links STUDENT (child) to GUARDIAN (parent) through GUID.

The real ATTENDANCE and STUDENT schema (this chapter)

The chapter's own Activity 9.4 defines ATTENDANCE with three columns, matching Table 9.5:

CREATE TABLE ATTENDANCE (
    AttendanceDate DATE,
    RollNumber INT,
    AttendanceStatus CHAR(1)
);

(AttendanceDate, RollNumber) together form the composite primary key of ATTENDANCE (added earlier in this section with ALTER TABLE ATTENDANCE ADD PRIMARY KEY (AttendanceDate, RollNumber);). RollNumber is also the column that must be a foreign key, because every attendance record has to belong to a real student — exactly the same role GUID plays linking STUDENT to GUARDIAN.

Identifying the tables

  • ATTENDANCE — the referencing (child) table: it holds the foreign key column, RollNumber.
  • STUDENT — the referenced (parent) table: RollNumber is its primary key.

Adding the foreign key

ALTER TABLE ATTENDANCE
ADD FOREIGN KEY (RollNumber) REFERENCES STUDENT(RollNumber);
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.