Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

FK question

4 posts in General Discussion Last posting was on 2005-12-20 11:30:06.0Z
user Posted on 2005-11-22 20:44:22.0Z
From: user@domain.invalid
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: FK question
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: ip70-176-29-134.ph.ph.cox.net
X-Original-NNTP-Posting-Host: ip70-176-29-134.ph.ph.cox.net
Message-ID: <43838326$1@forums-1-dub>
Date: 22 Nov 2005 12:44:22 -0800
X-Trace: forums-1-dub 1132692262 70.176.29.134 (22 Nov 2005 12:44:22 -0800)
X-Original-Trace: 22 Nov 2005 12:44:22 -0800, ip70-176-29-134.ph.ph.cox.net
Lines: 25
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4980
Article PK: 8629

Hi -

I'm running ASA 9.0.2.3044 on Windows XP.

Here's my issue:
I want to create a foreign key between two tables but sometimes I won't
have a value for the a column in the child table. If it is there, I want
to be sure it's valid.

How do I do this?

table1 ( parent )
( c1 integer pk,
c2 varchar(100) )

table2 ( child )
( tc1 integer pk,
tc2 integer null,
tc3 integer null )

and the key is between table1.c1 and table2.tc2. Again, I may not have a
value for table2.tc2 but if I do, I want it to be valid (table1.c1 )

Thanks
E-


Glenn Paulley Posted on 2005-11-22 22:30:47.0Z
Newsgroups: ianywhere.public.general
Subject: Re: FK question
From: Glenn Paulley <paulley@ianywhere.com>
References: <43838326$1@forums-1-dub>
Organization: iAnywhere Solutions
Message-ID: <Xns9716B0F241054paulleyianywherecom@10.22.241.106>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: 10.25.99.149
X-Original-NNTP-Posting-Host: 10.25.99.149
Date: 22 Nov 2005 14:30:47 -0800
X-Trace: forums-1-dub 1132698647 10.25.99.149 (22 Nov 2005 14:30:47 -0800)
X-Original-Trace: 22 Nov 2005 14:30:47 -0800, 10.25.99.149
Lines: 50
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4983
Article PK: 8632

Use a NULL value in table2.tc2. NULL values do not violate referential
integrity constraints.

Glenn

user@domain.invalid wrote in news:43838326$1@forums-1-dub:

> Hi -
>
> I'm running ASA 9.0.2.3044 on Windows XP.
>
> Here's my issue:
> I want to create a foreign key between two tables but sometimes I won't
> have a value for the a column in the child table. If it is there, I
want
> to be sure it's valid.
>
> How do I do this?
>
> table1 ( parent )
> ( c1 integer pk,
> c2 varchar(100) )
>
> table2 ( child )
> ( tc1 integer pk,
> tc2 integer null,
> tc3 integer null )
>
> and the key is between table1.c1 and table2.tc2. Again, I may not have
a
> value for table2.tc2 but if I do, I want it to be valid (table1.c1 )
>
> Thanks
> E-
>

--
Glenn Paulley
Research and Development Manager, Query Processing
iAnywhere Solutions Engineering

EBF's and Patches: http://downloads.sybase.com
choose SQL Anywhere Studio >> change 'time frame' to all

To Submit Bug Reports: http://casexpress.sybase.com/cx/cx.stm

SQL Anywhere Studio Supported Platforms and Support Status
http://my.sybase.com/detail?id=1002288


"Pavel Karady" <pavel_ns.ns_karady Posted on 2005-12-20 11:30:06.0Z
From: "Pavel Karady" <pavel_ns.ns_karady@ns_kogerusa.com>
Newsgroups: ianywhere.public.general
References: <43838326$1@forums-1-dub>
Subject: Re: FK question
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 217.75.90.162
X-Original-NNTP-Posting-Host: 217.75.90.162
Message-ID: <43a7eb3e$1@forums-1-dub>
Date: 20 Dec 2005 03:30:06 -0800
X-Trace: forums-1-dub 1135078206 217.75.90.162 (20 Dec 2005 03:30:06 -0800)
X-Original-Trace: 20 Dec 2005 03:30:06 -0800, 217.75.90.162
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:5077
Article PK: 17497

I think I get what you want to accomplish - please read the part about
WAIT_FOR_COMMIT in the fine manual.

Pavel

<user@domain.invalid> wrote in message news:43838326$1@forums-1-dub...
> Hi -
>
> I'm running ASA 9.0.2.3044 on Windows XP.
>
> Here's my issue:
> I want to create a foreign key between two tables but sometimes I won't
> have a value for the a column in the child table. If it is there, I want
> to be sure it's valid.
>
> How do I do this?
>
> table1 ( parent )
> ( c1 integer pk,
> c2 varchar(100) )
>
> table2 ( child )
> ( tc1 integer pk,
> tc2 integer null,
> tc3 integer null )
>
> and the key is between table1.c1 and table2.tc2. Again, I may not have a
> value for table2.tc2 but if I do, I want it to be valid (table1.c1 )
>
> Thanks
> E-


Greg Fenton Posted on 2005-11-22 22:30:20.0Z
From: Greg Fenton <greg.fenton_NOSPAM_@ianywhere.com>
Organization: iAnywhere Solutions Inc.
User-Agent: Mozilla Thunderbird 1.6.3.2f (Windows/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: FK question
References: <43838326$1@forums-1-dub>
In-Reply-To: <43838326$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: gfenton-t30.sybase.com
X-Original-NNTP-Posting-Host: gfenton-t30.sybase.com
Message-ID: <43839bfc$1@forums-1-dub>
Date: 22 Nov 2005 14:30:20 -0800
X-Trace: forums-1-dub 1132698620 10.25.98.144 (22 Nov 2005 14:30:20 -0800)
X-Original-Trace: 22 Nov 2005 14:30:20 -0800, gfenton-t30.sybase.com
Lines: 26
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4982
Article PK: 31504


user@domain.invalid wrote:
> table1 ( parent )
> ( c1 integer pk,
> c2 varchar(100) )
>
> table2 ( child )
> ( tc1 integer pk,
> tc2 integer null,
> tc3 integer null,

FOREIGN KEY tc2 REFERENCES table1(c1) );


Since tc2 is nullable, if you don't have a value (i.e. it is NULL) then
the check for a value in table1.c1 won't happen. If a value is
attempted to be inserted to tc2, then the foreign key constraint kicks
in and the value must exist in table1.c1.

Hope this helps,
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/