Hello,I have the following table:create table dbo.PostsTags( PostId uniqueidentifier not null, TagId uniqueidentifier not null, constraint PK_PostsTags primary key clustered (PostId, TagId), constraint FK_PostsTags_Posts foreign key(PostId) references Posts(Id) on delete cascade, constraint FK_PostsTags_Tags foreign key(TagId) references Tags(Id) on delete cascade) -- PostsTags
I want to create the constrains after the the table. alter table dbo.PostsTags add constraint PK_PostsTags primary key clustered (PostId, TagId),add constraint FK_PostsTags_Posts foreign key(PostId) references Posts(Id) on delete cascade,add constraint FK_PostsTags_Tags foreign key(TagId) references Tags(Id) on delete cascadego
1) Is this the correct way to do it?2) Should I also define the Primary Key constraint of my tables this way or should I create it within the table and leave only the constrains between tables to be defined after it (I think this is more correct, right)?3) Also related to constrains I have been seeing a lot BIT columns with a constraint:IsAnonymous bit not null constraint DF_User_IsAnonymous default (0)
Why is a constraint named DF is added to Bit columns?Thanks,Miguel