Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Limiting entries into the column
Message
De
28/02/2003 13:31:26
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
00759382
Message ID:
00759540
Vues:
21
>If my field can be either Y or N, how can I specify it? Or if the field can be only one of 3 predefined values?

Do you want to limit the column to only containing one of those discrete values? If so, you'll want to add a CHECK constraint to the table:

CREATE TABLE mytable (
gender nchar(1) CHECK(gender IN ('m', 'f'))
...
)

>Also, is it right to create one index with three columns? One of the fields is FK, two others just regular fields, but may be useful in joins or where clause...

Tricking question. What would be the definition of "right?" SQL Server does support composite indexes. The real question is whether the query optimizer will decide that the index is usable and that decision will be on a per query basis.

-Mike

>Hi everybody,
>
>If my field can be either Y or N, how can I specify it? Or if the field can be only one of 3 predefined values?
>
>Also, is it right to create one index with three columns? One of the fields is FK, two others just regular fields, but may be useful in joins or where clause...
>
>I've generated relationship:
>ALTER TABLE dbo.CartDetail ADD CONSTRAINT
>	FK_CartDetail_CartContent FOREIGN KEY
>	(
>	CartContentID
>	) REFERENCES dbo.CartContent
>	(
>	CartContentID
>	) ON UPDATE CASCADE
>	 ON DELETE CASCADE
>	
>GO
>
>It is the same, as triggers? Or should I do something different?
>
>
>
>Thanks in advance.
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform