module design question
Good morning,
I'm getting ready to begin a drupal project where I'll be writing several new modules. I have an existing database consisting of about 10 related tables. Some of these tables are related to each other via foreign keys and I'm trying to figure out the best way to develop the new module (or modules) to accomodate everything.
As an example, there are the following tables:
contacts
products
projects
Each of these tables has a foreign key to a "company" table. Therefore a contact can be associated with a company and a product can be associated with a company and a project can be associated with a company. I've already migrated the contact data to the drupal users and profile tables.
My question is this: is it best to make each table it's own module or should I try to combine as many as possible into a single module? The other tables in the existing DB have similar relationships. What's the best way to approach something like this from a module development point of view?
Any ideas?
Thanks in advance,
-mike

If it's one project
Start with one module.
Splitting modules off implies that each one can be enabled or disabled totally independantly of the other.
This is good for testing, but if any part of your code is going to assume the other parts are there, keep it together.
Just opinion without any understanding of how big the thing really is. If it's too big, feel free to split bits into includes.
Either several modules that include_once the common stuff, or one handler module that passes the hard work off to libraries... Design decision.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
manage hooks?
dman,
Thanks for the quick response. If I keep everything as a single module, how do I manage all the various hooks for each content type? Ideally, I'd have just 3 or 4 main content types (company, product, project, etc...) while the rest of the tables would just be linked to the main content types via foreign keys. How would I manage the various hooks for each content type? Via switch statements?
Do you know of any existing modules or resources that deal with this sort of design that I can check out?
Thanks in advance,
-mike
No problem, node content
No problem, node content type hooks are are named different! No reason they can't live happily in the same file.
It's not required for different modules to be in different files, although it would help conceptually.
If you are really having to define new content types, maybe they should be separate.
I know there are one or two modules that define more than one content type. Can't recall right now.
Start from
http://api.drupal.org/api/4.7/function/hook_node_info - you see it allows multiple declarations.
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
thanks
.dan.,
I just sent you a message offline.
Thanks,
-mike