Let's say that we want to create a site for a car dealership, and the first part of the site that we want to develop is the vehicle listings. These vehicle listings will give the users all of the information that they need to make an informed decision on what to buy.
So let's start thinking about how we might start modeling our data in Drupal to add these vehicle listings. First we define what kind of information we want to give about the vehicles. For the purpose of simplicity lets say that our vehicle listings will only have three pieces of information: make, model, and year.
Also, we want to add some information that is only relevant to trucks: whether their bed is covered or open. Let's call this piece of information the type of bed.
So, after we have defined all of the information relevant to our site, we know that we will have car listings which are composed of make, model, and year. Also we found out that we have two kinds of vehicle listings: listings for cars and listings for trucks. We need to make this distinction because we have information that is relevant to trucks (bed type), but not to cars.
Connecting the Example with Entity's Terminology
In the Drupal entity system we have a number of terms that might not be immediately intuitive. The most important terms are entity type, bundle, property, field, and entity.
Let's start with entity types:
Entity Type and Properties
An entity type is a grouping of objects. In Drupal core we already have some entity types defined for us: user, node, taxonomy term, etc. In our example we also have a general grouping of objects: vehicles. A grouping of objects is defined by the characteristics of those objects. For example, in Drupal core all user objects have a name and an email address. In our example, we also have certain characteristics, information, that is relevant to our entity type (vehicles). This information is what we call properties in Drupal terminology. The properties that we defined as relevant for all our vehicle objects are: make, model, and year.
Bundles and Fields
In our example, we also mentioned having two kinds, or types, of vehicles: cars and trucks. The reason that we made that distinction between cars and trucks is that we need to have some information that is only relevant to trucks. So how can we do this? If we add bed_type as a property to the entity type, all vehicles will have that property even if it is not relevant to all vehicles (in other words, it is not relevant to cars). Drupal gives us a way to solve that dilemma, by allowing us to subtype entity types. In our case we will have two subtypes: car and truck. After a bundle is created, we can add information to that bundle that is only relevant to that subtype, like add the bed_type property. A property that is only relevant to a subtype is called a field.
Finally, after we have created our entity type with its properties, and the bundles with their fields, we can start adding actual objects to our site: the cars and trucks. Each specific object of an entity type is referred to as an entity. So in our example a 1993 Toyota Corolla, and a 2000 Ford Ranger with an open bed, can both be examples of entities of our vehicle entity type.
Now we can actually implement our example by using the Entity Construction Kit (ECK) module. There are two paths for using ECK. If you like to do everything from code, follow the developers path, otherwise use the ECK UI to develop your data models by following the site builders path. Beyond implementing our example, the developers path also contains information on how to extend ECK and its functionality.