What are relationships used for?

  • Hi gurus!

    A kinda silly question but what are relationships between tables used for? Can you UPDATE/DELETE rows based on relationships? Do relationships speed up JOINs? Or do you use them only for data integrity?

    /Tomi

  • Used for data integrity. Not going to make joins faster, indexing is where you get speed - if anything foreignkeys may slow down operations slightly. You can update/delete rows using the CASCADE feature in SQL2K, or you could write some code to figure out the relationships and do the same thing in SQL7.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • Creating a data diagram provides the system with information it needs to know the relationships between/among the various tables. It helps the user create constraints, automatically generate triggers, or utilize referential integrity with cascading updates or deletes. For instance, if a table is related to various other tables through a foreign key and the user were to delete the record the system will have enough information to cascade these changes/deletes to all the related records. Vendors generally provide graphical tools, like the data diagrams, to allow the user to enforce integrity. It is a tool to help the user establish and maintain database integrity.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply