June 6, 2005 at 12:16 pm
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.
June 6, 2005 at 12:21 pm
I1 = Index
U1 = Unique Constaint
A.J.
DBA with an attitude
June 6, 2005 at 12:38 pm
Thanks for the fast reply. Would you mind taking this a step further and give me an example usage of each? Thanks in advance.
June 7, 2005 at 12:37 am
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