3

I am building an admin site for my brother's property management company. The design seems pretty straight forward.

I need a database with tables to store:

Estates. Each estate has a number or properties (flats or houses). Each property has a number of charges (service charge, water bills, maintenance ect.)

Then I have: Owners. Each Owner must have ONE or MORE properties. Owners make payments. Each payment is allocated to ONE or MORE charges.

From there I add CRUD functionality and the ability to produce reports by estate, property and/or owner.

Being new to Drupal I originally thought that the way to do this is create a content-type for each of the tables (e.g Estate, property, charge, owner, payment) and then use the relations module to enforce any foreign keys and automatic additions and update.

However, I have spent this week reading pro drupal development 7 and now I see I can build the database using the schema module and add functionality through the database abstraction layer with the functions declared in database.inc.

Does anyone have an opinion on which is the best way forward? Or am I missing the point a bit? Do I use them both?

Thanks for any advice and Merry Christmas (or Happy Holidays, whichever you prefer)

2

Reasons you should go with content type.

  • Its is what you get out of box from drupal, content type are built on drupal entity concept,lot of api's are exposed to alter the default workflow in case needed,internally it does the same that you can do with custom tables,a lot of contributed modules are there to extend the functionality.
  • If you are planning to have custom tables then you have to write codes at each point of three layers -tables creation, data insertion/updation, data view,while using content type you can get it done by drupal core and by using some of contributed modules for example to show different data you can use views.

Following modules can be helpfull for the functionalities listed above.

  1. views.
  2. entityreference

Things you need to plan Try to categorize the listed (Estate, property, charge, owner, payment) into entities and their properties for example charge might not be a separate entity instead it might be a property(field) of property(content type). So roughly you can have Estate,property as content type. Once you install entityreference module, it will allow you to setup reference from property to estate using reference field(provided by entity reference module).So setting up reference you can establish relationship of what property nodes belong to what estate nodes.Charge can simply a field on property content type, so it will show charge/cost for a property node.Owner can be nodes or if you allow login to owner you can make theme drupal users as well.Again you can setup by relationship between property and owner using reference field in both ways keeping it as users or as node.

I hope this might be helpful in starting,Merry Christmas :)

  • Yes, that is very helpful, thanks. So each content type is an entity? I think, as a property can have a large number of charges and charges can be of different types (service, utilities, fines ect.) that a charge should be a separate entity and therefore its own content type. Is that the right kind of logic? – NectarSoft Dec 23 '13 at 1:05
  • Okay, I have done a bit more reading. A node is an entity and content type is a 'bundle' created from a node. So when you say I should plan whether charge is a separate 'entity' I guess you mean 'content type' as I doubt I need to create custom entities for any of the attributes mentioned. Or do I have to define custom entities if I want to use reference filed? Or in other words, can I extend node entities to contain reference fields? – NectarSoft Dec 23 '13 at 1:49
  • yes when I am saying as separate entity I mean a different content type.You do not have to declare any custom entities, you can use the reference field out of the box to reference nodes from content type to another. – arpitr Dec 23 '13 at 5:44
1

Here is a link to a comment that answers the question I asked. It backs up what arpitr outlined in their answer above.

https://drupal.org/comment/7848011#comment-7848011

I will implement my system using node entities until the need arises to build a custom entity (if it ever does).

The top answer in this forum give a good way to evaluate whether to use nodes or custom build an entity:

When is it appropriate to create an Entity versus just adding a new content type?

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.