I am designing erd for campground and campsite. In general, a campground has many campsites in it. that lead to one to many relationships. but sometimes campsite has no campground, it appears as the single entity with no parent. then what relationship should be used for these?

  • I guess it depends on your definition of those terms. Why can't a campsite with no formal campground, be both campsite and campground? Or maybe campground has dimensions Description, Longitude, Latitude, etc. The point being you can define the entities at the start and morph the definitions, as needed. – Steve Mangiameli Mar 18 '15 at 17:13
  • campground and campsite almost has same description keys, but the differnce is that multiple campsite can be belongs to an campground or belongs to none. – Muhammad Taqi Mar 18 '15 at 18:07

This is quite normal in database design. If you look at this guide about cardinality notations you will see that one option is zero to one (optional) (one campsite has zero to one campgrounds).

In SQL you do it by making a FOREIGN KEY constraint from campsite to campground and not declaring the foreign key id in campsite as NOT NULL.


What I would advise you to do is to Google "open source campsite software" (I got 2 million results). Then download a few of these and explore which one(s) correspond to your needs and then adapt and develop according to your abilities. That's the great thing about F/LOSS - it allows you to see database schemas and code in action.

In answer to your specific question, why not allow a campsite to also be a campground with itself as its own default campsite? In this scenario, a child can be its own parent - not uncommon in the employee/manager scenario where the CEO is his own boss.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.