Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do Relationships work in SQL 7.0
Message
From
02/03/2000 20:50:14
 
 
General information
Forum:
Microsoft SQL Server
Category:
Database design
Miscellaneous
Thread ID:
00340537
Message ID:
00341007
Views:
29
>Can somebody give me a run down on how to create a one to many relationship in SQL 7.0. You know the classic "One Invoice has many items"
>
>INVHD.Number has many INVITEMS.Number ?
>
>Thanks

You really don't need to any thing special except create the two related tables. But, what I think you want to know is how to set it up so the SQL Server knows about the relationship and does some policing of it.

What you want to do is add a Foreign Key constraint to the child table. In your example... lets say the Invoice table has a PK of InvoiceID and the InvoiceDetail table has a FK or InvoiceID... send a command like this...

ALTER TABLE InvoiceDetail ADD CONSTRAINT InvoiceID
FOREIGN KEY (InvoiceID) REFERENCES Invoice(InvoiceID)

HTH,
BOb
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform