Re: Index for username/password



David Portas wrote:

> Cecil wrote:
>
> > >>I don't see the purpose of the ID column? Why not make the name the primary
> > >>key?
> >
> > I was thinking of doing that, but I intend for the Logon table to be
> > like an ID card. Only for efficient identification. I wanted to reuse
> > this table design in multiple projects that would require
> > authentication.
> >
>
> Name would still be unique though wouldn't it? So it should still have
> a unique constraint on name.
>

Apologies, I see that you have declared a unique INDEX on name. A
unique CONSTRAINT is virtually equivalent however and is usually the
preferred choice rather than an index.

--
David Portas
SQL Server MVP
--

.



Relevant Pages

  • Re: foreign keys
    ... The column referenced by a foreign key has to be unique, ... PRIMARY KEY or UNIQUE constraint. ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Create a constraint
    ... > Sounds like you need a UNIQUE constraint. ... > ALTER TABLE SomeTable ADD CONSTRAINT UQ_xyz UNIQUE ... > David Portas ... > SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: **HAVE NULL AND NOT DUBLICATED VALUES IN COL**
    ... if you define colx as UNIQUE then the trigger will not fire. ... trigger is something you can use instead of a unique constraint. ... David Portas ...
    (microsoft.public.sqlserver.programming)
  • Re: Create a constraint
    ... Sounds like you need a UNIQUE constraint. ... ALTER TABLE SomeTable ADD CONSTRAINT UQ_xyz UNIQUE ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Difference between creating a Unique Constraint and a Unique Index
    ... I have two real life examples where I would use a unique index as ... ,CONSTRAINT PK_StudentCourses PRIMARY KEY (StudentID, CourseID) ... In this case there already is a unique constraint on (StudentID, ...
    (microsoft.public.sqlserver.server)