Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Constraints in SQL Server 2000
Message
From
14/03/2008 23:42:29
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
 
To
14/03/2008 23:39:04
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01302373
Message ID:
01302375
Views:
7
I think that's the answer, thanks! Contraints seem fairly straightforward.

>You could use referential integrity and set it up as a foreign key. Will there ever be orphan queue records or will there always be a matching record in the Folders table? Is queue a child table? Are there any rules you want enforced between the two tables?
>
>Here is one example:
>
>ALTER TABLE DBO.QUEUE
>ADD CONSTRAINT FK_QUEUE_FOLDER FOREIGN KEY (FOLDER)
>REFERENCES DBO.FOLDERS(FOLDER)
>ON DELETE CASCADE
>
>(not tested)
>
>In the above, a queue row cannot exist without an associated folders row. The ON DELETE CASCADE option tells the database engine that if the parent folders row’s folder is deleted, then any queue tied to the folders by the deleted folder should be automatically deleted as well.
>
>(Hope I typed that right = it is somewhat confusing because the table is named folder and the field is folder and the child table (?) is named queue and has a foreign key (?) field of folder if I understood you correctly)
>
>
>>Hopefully a simple question, but I don't have much experience with writing contraints in SQL Server.
>>
>>I have one table called Folders with an ID field (autonumber PK) and a Folder field (varchar unique). This contains a list of folders.
>>
>>I have a second table called Queue. It has several fields, one of which being Folder (corresponds to the Folder field in the first table). How do I write a constraint to enforce that the contents of the Folder field in the Queue table exists in the Folder field in the Folders table?
>>
>>Thanks!
Very fitting: http://xkcd.com/386/
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform