Advertisements
Advertisements
Question
Name foreign keys in table ATTENDANCE and STUDENT. Is there any foreign key in table GUARDIAN.
ATTENDANCE
| Attribute Name | Data expected to be stored | Data Type | Constraint |
|---|---|---|---|
| RollNumber | Numeric value consisting of maximum 3 digits | INT | PRIMARY KEY |
| SName | Variant length string of maximum 20 characters | VARCHAR(20) | NOT NULL |
| SDateofBirth | Date value | DATE | NOT NULL |
| GUID | Numeric value consisting of 12 digits | CHAR(12) | FOREIGN KEY |
STUDENT
| Attribute Name | Data expected to be stored | Data Type | Constraint |
|---|---|---|---|
| GUID | Numeric value consisting of 12 digit Aadhaar number | CHAR(12) | PRIMARY KEY |
| GName | Variant length string of maximum 20 characters | VARCHAR(20) | NOT NULL |
| GPhone | Numeric value consisting of 10 digits | CHAR(10) | NULL UNIQUE |
| GAddress | Variant length string of size 30 characters | VARCHAR(30) | NOT NULL |
GUARDIAN
| Attribute Name | Data expected to be stored | Data Type | Constraint |
|---|---|---|---|
| AttendanceDate | Date value | DATE | PRIMARY KEY* |
| RollNumber | Numeric value consisting of maximum 3 digits | INT | PRIMARY KEY*, FOREIGN KEY |
| AttendanceStatus | ‘P’ for present and ‘A’ for absent | CHAR(1) | NOT NULL |
Code Writing
Advertisements
Solution
- STUDENT table:
GUIDis a Foreign Key. It refers toGUIDin the GUARDIAN table. - ATTENDANCE table:
RollNumberis a Foreign Key. It refers toRollNumberin the STUDENT table. - GUARDIAN table: There is no Foreign Key.
GUIDis its Primary Key.
| Table | Foreign Key | References |
|---|---|---|
| STUDENT | GUID |
GUARDIAN(GUID) |
| ATTENDANCE | RollNumber |
STUDENT(RollNumber) |
| GUARDIAN | None | , |
The foreign key in STUDENT is GUID, and the foreign key in ATTENDANCE is RollNumber. There is no foreign key in the GUARDIAN table.
shaalaa.com
Is there an error in this question or solution?
