ER Diagram/Data Model

  • I'm new to SQL and have a basic question.

    What does "U1" and "I1" signify in an ER Diagram when written next to a column for a given table? These seem to be fundamental like "PK" = Primary Key and "FK" = Foreign Key but I haven't seen them before.

  • I1 = Index

    U1 = Unique Constaint



    A.J.
    DBA with an attitude

  • Thanks for the fast reply. Would you mind taking this a step further and give me an example usage of each? Thanks in advance.

  • CREATE TABLE Employee (

     EmpID varchar(20) NOT NULL,

     SSN varchar(11) NOT NULL,

     Phone varchar(14) NULL

    )

    GO

    -- Example of a PK

    ALTER TABLE Employee

     ADD CONSTRAINT Employee_PK PRIMARY KEY clustered (EmpID)  

    GO

    -- Example of a U1

    -- I cannot see a reason why a unique valued field should not be

    -- indexed unique as well, as it can be an alternate key

    ALTER TABLE Employee ADD CONSTRAINT Employee_UC UNIQUE (SSN)

    GO

    CREATE UNIQUE index Employee_AK ON Employee (SSN)

    GO

    -- Example of an I1

    CREATE index Employee_Phone_IX ON Employee (Phone)

    GO

    Andy

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply