CodeIgniter Forums

Full Version: Regional newsletters. Oh, and national newsletters...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hi, guys.

I have a question and I'm hoping you might be able to help me.

I'm doing a free project for a friends' organisation, and he wanted the ability to post regional newsletters.

I have a database table for newsletters, which joins onto the members table and regions table. However, he's now asked if we can also allow posting of national newsletters. I'm not quite sure how to proceed, since I only took regional newsletters into account.

I was thinking of simply setting the region ID to 0 for national newsletters, but I'm unsure. I don't know if I should handle this with the regional newsletters, or if I should have a separate table and controller for national newsletters. Setting the region ID to 0 is a quick fix, but in the unlikely event he decides to add another kind of newsletter, it's going to cause problems.

I would really appreciate anyone's thoughts on the matter. I understand there are several ways to go about this, but I'm sure there's a way I haven't thought of that's probably better than any of the methods I have already thought of.

Many thanks in advance.

El Forum

[eluser]Rok Biderman[/eluser]
I would do it the way you propose. I don't see how it could create problems if additional newsletters are required. In that (you say unlikely) case I would just use either a very large code (if you have 50 regions, you could start with your special newletters from 1000) or a negative number. Then when you do your joins you just don't select all records (you arent going to with you proposed solution anyway), but only numbers equal or greater than one or numbers smaller than 1000. I somehow better like the big numbers.

El Forum

Hi TheFuzzyOne,

How about creating a newsletter_type table?
-- Table structure for table `newsletter_type`


Of course you would need to link the newsletter_type region_id to - your region ID.
This way if your client asks you to add more you could build it into your admin backend.

El Forum

Thanks for your input guys. I really appreciate it.

I think I'll add a column to the newsletter table for newsletter type. That way I can have two models, and each can pull their data differently as required (since national newsletter don't need to be joined with the region table).

Many thanks again! Smile