sql server 2005 - Unique Constraint doesn't appear to be constraining anything -


i have table called models set follows:

  1. id - pk, identity
  2. manufacturer fk - int32
  3. primodel fk - int32
  4. secmodel fk - int32
  5. formfactor fk - int32
  6. active char(1)

what want columns 2,3,4,5 accept unique set of values. ran:

alter table dbo.models add constraint uc_models unique (manufacturer, primodel, secmodel, formfactor) 

the command reported completed , see index added, not constraint. able create duplicate of cols 2-5 insert , update commands. i'm not sure if issue foreign keys or else altogether.

use [inventory_v2] go       /****** object:  table [dbo].[models]    script date: 4/8/2013 2:01:41 pm ******/     set ansi_nulls on     go      set quoted_identifier on     go      set ansi_padding on     go      create table [dbo].[models](         [id] [int] identity(1,1) not null,         [manufacturer] [int] not null,         [primodel] [int] not null,         [secmodel] [int] not null,         [formfactor] [int] not null,         [active] [char](1) not null,      constraint [pk_models] primary key clustered      (         [id] asc     )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary],      constraint [uc_models] unique nonclustered      (         [manufacturer] asc,         [primodel] asc,         [secmodel] asc,         [formfactor] asc     )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary]     ) on [primary]      go      set ansi_padding off     go      alter table [dbo].[models]  check add  constraint [fk_models_models_formfactor] foreign key([formfactor])     references [dbo].[models_formfactor] ([id])     go      alter table [dbo].[models] check constraint [fk_models_models_formfactor]     go      alter table [dbo].[models]  check add  constraint [fk_models_models_oems] foreign key([manufacturer])     references [dbo].[models_oems] ([id])     go      alter table [dbo].[models] check constraint [fk_models_models_oems]     go      alter table [dbo].[models]  check add  constraint [fk_models_models_primodels] foreign key([primodel])     references [dbo].[models_primodels] ([id])     go      alter table [dbo].[models] check constraint [fk_models_models_primodels]     go      alter table [dbo].[models]  check add  constraint [fk_models_models_secmodels] foreign key([secmodel])     references [dbo].[models_secmodels] ([id])     go      alter table [dbo].[models] check constraint [fk_models_models_secmodels]     go 


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -