One-to-many relationship need entry on the many side?

P

Pamela

Would it violate referential integrity to, for test reasons, input entries
into the "one" side without at least one entry on the "many" side? Thanks!
 
J

John W. Vinson

Would it violate referential integrity to, for test reasons, input entries
into the "one" side without at least one entry on the "many" side? Thanks!

No. You can have a chicken that hasn't laid any eggs, but you can't have an
egg unless you have a chicken to lay it.

In fact, the situation you describe will ALWAYS exist at some point - you've
got to enter the parent record first, before you're even able to create child
records.
 
G

Graham Mandeno

Hi Pamela

No, not at all. It happens all the time. Consider a new customer who
hasn't yet made any purchases.

In fact, you MUST create the record on the one side before you can create
any related records on the many side.
 
P

Pamela

Thank you - that was my logic but I have been running into some problems that
I think stem from my relationships and wanted to make sure that that scenario
wasn't the root.
 
P

Pamela

Thank you - that was my logic but I have been running into some problems that
I think stem from my relationships and wanted to make sure that that scenario
wasn't the root.

Graham Mandeno said:
Hi Pamela

No, not at all. It happens all the time. Consider a new customer who
hasn't yet made any purchases.

In fact, you MUST create the record on the one side before you can create
any related records on the many side.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Pamela said:
Would it violate referential integrity to, for test reasons, input entries
into the "one" side without at least one entry on the "many" side?
Thanks!
 
A

Armen Stein

No. You can have a chicken that hasn't laid any eggs, but you can't have an
egg unless you have a chicken to lay it.

In fact, the situation you describe will ALWAYS exist at some point - you've
got to enter the parent record first, before you're even able to create child
records.

Nice explanation John.

But I'll also add that you have to decide whether the foreign key in
the child table is required. Many people think that a foreign key
with a null value violates referential integrity. It doesn't. You
can use the Required property to control whether the field must have a
value. Referential Integrity will ensure that if it does have a
value, that the value is valid (exists in the related table).

So, you can have an egg who doesn't know who its mommy is, and still
meet referential integrity. It's up to you to specify Required if you
don't want this sad situation.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top