Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2010
    Posts
    3

    Cool Unanswered: Microsoft SQL Server 2008 Constraints ?

    Hi All,

    This is my first post in this forums.

    Does SQL Server 2008, have any limitations in accepting
    explicitly declared multiple foreign keys, example as follows :

    CREATE TABLE PracticalSession
    (
    StudentNo CHAR(5), /* Belongs To Trainees Table */
    EmployeeNo CHAR(4), /* Belongs To DrivingInstructors Table */
    RegistrationNo CHAR(6), /* Belongs To Vehicles Table */
    PracticalDate DATE,
    StartTime TIME

    PK (PracticalDate, StartTime, StudentNo, EmployeeNo, RegistrationNo),
    FK (StudentNo) REFERENCES Trainees (StudentNo)
    FK (EmployeeNo) REFERENCES DrivingInstructors (EmployeeNo)
    FK (RegistrationNo) REFERENCES Vehicles (RegistrationNo)
    );

    Scenario : When a student goes for a driving lesson, the student and instructor are assigned to a vehicle.

    Thanks in Advance.

  2. #2
    Join Date
    Nov 2005
    Posts
    122
    Read here: FOREIGN KEY Constraints

    I'm not sure if the 253 limit is a best practise or if SQL Server will throw an exception when creating the 254th fk constraint.

  3. #3
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    Multiple foreign keys are perfectly OK. The main restriction is that columns in the constraint must exactly match the list of columns in a UNIQUE or PRIMARY KEY constraint or unique index.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •