<div dir="ltr">Hello, Joseph,<div><br></div><div>You have to define either Primary Key or Unique constraint in the parent table before a Foreign Key creation.</div><div><br></div><div>So to get the last query working, you can declare structure of the second table:</div>
<div><div>CREATE TABLE "InvoiceItems"(</div><div> "InvoiceKey" ULONG <b>UNIQUE</b>,</div><div> "rowID" ULONG METHOD ( 'RecID' ) );</div></div><div><br></div><div>Or just make rowID method unique via the Property Inspector.</div>
<div><br></div><div>------------------------------------</div><div>But looking at the names of tables, I think you wanted to create a db schema,</div><div>where each row in InvoiceItems points to one parent row in Invoices1 table:</div>
<div><br></div><div><div><br></div><div>CREATE TABLE "Invoices1"(</div><div> "InvoiceDate" DATE,</div><div> "field1" ULONG,</div><div> "rowID" ULONG METHOD ( 'RecID' ) <b>UNIQUE</b> );</div>
<div><br></div><div><br></div><div>CREATE TABLE "InvoiceItems"(</div><div> "InvoiceKey" ULONG,</div><div> "rowID" ULONG METHOD ( 'RecID' ) );</div><div><br></div><div>-- CREATE LINK "lnk_InvoiceItems_Invoices12" -------------------</div>
<div>ALTER TABLE "InvoiceItems" ADD CONSTRAINT "lnk_InvoiceItems_Invoices12" </div><div><span class="" style="white-space:pre"> </span>FOREIGN KEY( "InvoiceKey" )</div><div><span class="" style="white-space:pre"> </span>REFERENCES "Invoices1" ( "rowID" )</div>
<div><span class="" style="white-space:pre"> </span>ON DELETE RESTRICT </div><div><span class="" style="white-space:pre"> </span>ON UPDATE SET DEFAULT;</div><div>-- -------------------------------------------------------------</div>
</div><div><br></div><div>Best regards,</div><div>Sergey Pashkov</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Oct 13, 2013 at 6:47 PM, Ruslan Zasukhin <span dir="ltr"><<a href="mailto:ruslan_zasukhin@valentina-db.com" target="_blank">ruslan_zasukhin@valentina-db.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 10/13/13 5:38 PM, "Joseph Morgan" <<a href="mailto:joseph@checkos.com">joseph@checkos.com</a>> wrote:<br>
<br>
Hi Joseph,<br>
<br>
</div><div class="im">> I tried to create the link in Vstudio.<br>
><br>
> Two Tables as example:<br>
><br>
> CREATE TABLE "Invoices1"(<br>
> "InvoiceDate" DATE,<br>
> "field1" ULONG,<br>
> "rowID" ULONG METHOD ( 'RecID' ) );<br>
><br>
><br>
> CREATE TABLE "InvoiceItems"(<br>
> "InvoiceKey" ULONG,<br>
> "rowID" ULONG METHOD ( 'RecID' ) );<br>
<br>
</div>Hi Joseph,<br>
<br>
For FK-links, I will recommend use not CREATE LINK command,<br>
But something standard what have all other dbs.<br>
<br>
Example:<br>
<a href="http://www.w3schools.com/sql/sql_foreignkey.asp" target="_blank">http://www.w3schools.com/sql/sql_foreignkey.asp</a><br>
<br>
<br>
<br>
<br>
CREATE TABLE "InvoiceItems"(<br>
"InvoiceKey" ULONG FOREIGN KEY REFERENCES Persons(rowID),<br>
<div class="im"> "rowID" ULONG METHOD ( 'RecID' )<br>
);<br>
<br>
<br>
<br>
</div>===================<br>
Important notes:<br>
<br>
** If you want true ROWID, you can use new in 5.0 feature<br>
SEQUENCES, like in Postgre<br>
<br>
<br>
** if it is okay to use RecID itself, then you may want use<br>
RecID-ObjectPtr combination.<br>
<br>
It is more simple and more effective that FK-link.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
--<br>
Best regards,<br>
<br>
Ruslan Zasukhin<br>
VP Engineering and New Technology<br>
Paradigma Software, Inc<br>
<br>
Valentina - Joining Worlds of Information<br>
<a href="http://www.paradigmasoft.com" target="_blank">http://www.paradigmasoft.com</a><br>
<br>
[I feel the need: the need for speed]<br>
<br>
<br>
_______________________________________________<br>
Valentina mailing list<br>
<a href="mailto:Valentina@lists.macserve.net">Valentina@lists.macserve.net</a><br>
<a href="http://lists.macserve.net/mailman/listinfo/valentina" target="_blank">http://lists.macserve.net/mailman/listinfo/valentina</a><br>
<br>
</div></div></blockquote></div><br></div>