Search code examples
ms-accessrelationships

MS Access - Basic Relationship Error


I am trying to create a simple database of a theoretical car rental company. The following picture shows the relationships I currently have.

enter image description here

However, when I try to assign more than one car to a single customer, I get the following error message:

enter image description here

If anyone could advise me as to why this is coming up and what to change I would be very greatful, if more information is needed to figure this out just ask! Thanks


Solution

  • Your ER diagram's wrong. Assuming you want Zero, One Customer --> Many Cars, then the proper pattern is to insert the foreign key of the 0,1 into the table of the Many.

    So your Cars table should have a Foreign key of CustomerId.

    Customer table shouldn't know about Cars at all for normality.

    EDIT: Looking at the requirements/model, chances are this is many to many. I.e. Many customers over time rent a car or cars. In this case to maintain normality you need a junction table - e.g. cars-customers that has two primary keys, CustomerId and CarId. That's also where you'd put information about that relationship, like dates rented and the like.