Can we give unique and not null constraint to an attribute? how it is different from primary key?

Showing Answers 1 - 21 of 21 Answers

alok

  • Aug 1st, 2007
 

Unique+Not null can be defined in a table more than once.
Primary key has an index created for it implicietly.

  Was this answer useful?  Yes

               We can give the not null, unique constrints to the fields in the table. Actually the combination of the properties of these two constrins are present in the primary key constraint. If the primarykey constraint is divided into two parts the two parts will be UNIQE and NOT NULL.

  Was this answer useful?  Yes

NOT NULL: It allows duplicates, but doesn't allow null values
UNIQUE: It allows null values, but doesn't allow duplicates
PRIMARY KEY: It doesn't allows duplicates and null values

Unique index wil be created automatically for PRIMARY KEY, and UNIQUE constraints, but index wil not created implicitly 4  NOT NULL constraint.

There only one PRIMARY KEY wil be alowed 4 a table... we can create any number of NOT NULL+UNIQUE constraint 4 a table.

  Was this answer useful?  Yes

aytasirs

  • Nov 15th, 2012
 

We can create only 1 primary constraint per a table, But Can create more than 1 unique+Not null Constraints per a table.

  Was this answer useful?  Yes

EHSAN REHMANI

  • Apr 27th, 2013
 

There is only one primary key per table but we can use unique and not null constraints more than one column in a table. Primary key having both functionality as it can not be null but unique.

  Was this answer useful?  Yes

aytasirs

  • Apr 29th, 2013
 

Yes We can. If we use the combination "unique+not null" the referential integrity is not maintained and that is not the case with primary key.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions