Reputation: 1260
Session
SessionId (PK) SessionName SessionDuration TotalMarks SessionWeight ModuleId (FK)
1 AAA 01:00:00 30 20 1
Penalty
SessionId (PK) PenaltyEnalbed
1 1
My question is that as SessionId
in Penalty Table refers to the Session
Table, should SessionId
in penalty table be a primary key or a foriegn key?
Upvotes: 0
Views: 41
Reputation: 263703
SessionID
in table Penalty
should be define as FOREIGN KEY
since you have mentioned that it refers on column SessionID
of table Session
.
CREATE TABLE Session
(
SessionID INT PRIMARY KEY NOT NULL,
-- OTHER columns here...
);
CREATE TABLE Penalty
(
SessionID INT NOT NULL,
-- OTHER columns here...,
CONSTRAINT penalty_fk FOREIGN KEY (SessionID)
REFERENCES Session(SessionID)
);
Upvotes: 1
Reputation: 2597
it should be foreign key but in penalty there should also be an Id to set as primary key. So in penalty it should be ID(PK) SessionId (FK) PenaltyEnalbed
Upvotes: 1