Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: newbie question
On Mon, 13 Oct 1997 14:01:59 -0700, Bill Kincaid <wkincaid_at_mindspring.com> wrote:
>During the entry process of records into my Client table, I will allow
>the user to leave the Receipt_No field null. If the user enters a value
>into Receipt_No then I want to ensure that that value is not present in
>the Receipt table. If it is present then I want to disallow the record
>to be entered. The same goes for the VIN field and VIN table (including
>allowing a null in VIN field).
Are you sure, you made the right structure for your tables? With the presented datamodel, you have a one-to-many relationship from receipt to client. Don't you want the opposite? Like:
Client (client_no, VIN)
Receipt (client_no, receipt_no, <other fields>)
VIN (client_no, VIN, <other fields>)
Now, you can insert your client without problems. When you insert a record in the receipt table, the uniqueness of the receipt_no is enforced by the PK (implicit not null, unique constraint).
Your receipt table will have a foreign key from receipt.client_no to client.client_no.
The same for VIN.
![]() |
![]() |