Re: How to make a Foreing Key?
From: Jesus Cardenas (jesusc_at_tfs.grupo-ed.com)
Date: 10/15/04
- Next message: Scott Simons: "Re: Sum of values"
- Previous message: Peter B.L. Rasmussen: "Re: Changing a primary key data type"
- In reply to: John Bell: "RE: How to make a Foreing Key?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 15 Oct 2004 09:13:40 -0500
Hi John, below are the code DDL ,
Supose I have this tables DETAIL, HEADER and ITEMS and I want to add in the
table DETAIL a Foreing Key ITEMS.CUSTOMER , ITEMS.PRODUCT but I can't do
this. Because in the DETAIL table I don't have the field CUSTOMER
Should I ADD a field CUSTOMER in the table DETAIL to do that? or Is there
any another beter way?
Thanks!
CREATE TABLE [dbo].[detail] (
[entry] [int] NOT NULL ,
[line] [int] NOT NULL ,
[product] [int] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[header] (
[entry] [int] NOT NULL ,
[customer] [int] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[items] (
[customer] [int] NOT NULL ,
[product] [int] NOT NULL ,
[description] [varchar] (50) NULL
) ON [PRIMARY]
GO
"John Bell" <JohnBell@discussions.microsoft.com> wrote in message
news:55265E7B-28FF-4C13-8B8F-D684C6BD5161@microsoft.com...
> Hi
>
> Unfortunately your question is not that clear! Your column names are not
> obvious and without furhter knowledge of your system it is hard to answer.
> Posting DDL is always a lot clearer than pseudo code in this kind of
> situation http://www.aspfaq.com/etiquette.asp?id=5006
>
> If you have a master/detail situation, then you would normally have the
> master PK as part of a composite PK in the detail table. Your detail/items
> table seem to be trying to do the same thing.
>
>
> John
>
> "Jesus Cardenas" wrote:
>
> > I've this tables
> >
> > Header
> > entry
> > customer
> > ....
> >
> > Detail
> > entry
> > line
> > partnumber
> > ....
> >
> > Items
> > customer
> > partnumber
> > description
> >
> > How can I make a Relationships Detail - Item when I don't have the field
> > customer in the table Detail
> >
> > I've MSSQL 7
> >
> > I hope the cuestin is clear...
> >
> > Thanks in advance ...
> >
> >
> >
- Next message: Scott Simons: "Re: Sum of values"
- Previous message: Peter B.L. Rasmussen: "Re: Changing a primary key data type"
- In reply to: John Bell: "RE: How to make a Foreing Key?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|