CREATE TABLE T_SalesAgent (
    SalesAgentID BIGINT NOT NULL,
    AgentID BIGINT NOT NULL,
    BranchID BIGINT NOT NULL,
    ReferenceSalesAgentStatusID BIGINT NOT NULL,
    ReferenceTableStatusID BIGINT NOT NULL DEFAULT 1,
    DateAdded DATETIME NOT NULL DEFAULT NOW(),
    AddedByUserID BIGINT NOT NULL,
    DateUpdated DATETIME,
    UpdatedByUserID BIGINT,
    PRIMARY KEY (SalesAgentID),
    CONSTRAINT FK_SalesAgent_AgentID FOREIGN KEY (AgentID) REFERENCES M_Agent(AgentID),
   CONSTRAINT FK_SalesAgent_BranchID FOREIGN KEY (BranchID) REFERENCES M_Branch(BranchID),
   CONSTRAINT FK_SalesAgent_ReferenceSalesAgentStatusID FOREIGN KEY (ReferenceSalesAgentStatusID) REFERENCES M_Reference(ReferenceID),
   CONSTRAINT FK_SalesAgent_ReferenceTableStatusID FOREIGN KEY (ReferenceTableStatusID) REFERENCES M_Reference(ReferenceID) 
);