ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

general EE database design question..

August 11, 2008 11:34am

Subscribe [3]
  • #1 / Aug 11, 2008 11:34am

    yehosef

    17 posts

    I’ve noticed that the weblogs_data table contain fields for all possible custom fields (even those not applicable for that entry), and each new custom field modifies the weblog table structure.

    I wouldn’t have thought to solve the problem this way.  It would have seemed more elegant to create a weblog_field_data table which would have the data for each field for each record.  Then you could join the tables together and you’d get a result set of the fields for each entry.  As it is now - it seems that either you need to pull all the fields for each entry (which might not be a big deal because they are mostly empty) - or they need to create the weblog_data query based on the weblog_fields result.  (I haven’t looked through the code yet to see.. just speculating)

    So, since I see that the EllisLabs people seem to know what’s what (I mean, they made codeigniter) - I’m curious why they chose this route?  Is it faster or is a left-over from an old design decision?  Or is there some other benefit that I don’t understand.  The main drawback I see to the approach I’m suggesting is that the weblog_field_data table will have a lot of rows - but I would think with properly indexed tables, that wouldn’t slow things down much.

  • #2 / Aug 11, 2008 11:38am

    yehosef

    17 posts

    update - the reason I thought to ask this is because I was running into a situation where I would like to have multiple weblogs with custom fields of the same name (body, etc.) and it’s telling me I can’t.  So looking into it - i saw how the database is setup.  If someone knows a work around to having multiple custom fields of the same name, I would be interested to know.  Thanks.

  • #3 / Aug 11, 2008 7:24pm

    Joe Michaud

    154 posts

    How funny…  I was just pondering how I could accomplish the same thing - sharing fields between weblogs.

    Guess I’ll just subscribe to the thread and wait for replies.

  • #4 / Aug 12, 2008 5:52am

    yehosef

    17 posts

    The best approach I’ve thought of so far is to have the variables named systematically like: “weblog"_"var”
    so you can plug into loops like this

    {exp:weblog:entries weblog="posts1|posts2"}
    
    {title} - {{weblog}_subject} 
    
    {{weblog}_body}
    
    {/exp:weblog:entries}

    but it’s not so elegant in that I need to keep track of all these different variables and make different variable groups for weblog.  The case I’m working on I have 4 weblogs which contain maybe 5-6 custom fields that are the same and 5-6 that are different.  In a summary view, I want the similar fields to be displayed - then when someone drills down to the content, they’ll get the all the custom fields.

    I’d be interested in feedback in this or other approaches to solve this problem.

  • #5 / Aug 12, 2008 9:50am

    Sue Crocker

    26054 posts

    yehosef, why do you need to different field groups? You can use the same field group with multiple weblogs. Or does the second weblog require an additional field?

  • #6 / Aug 12, 2008 10:02am

    yehosef

    17 posts

    Yes - that’s the problem.

    The case I’m working on I have 4 weblogs which contain maybe 5-6 custom fields that are the same and 5-6 that are different.

    eg.  each of the four fields needs a email and phonenumber but one of them needs a url and the other needs a mailing address. etc.

    If there is some other way around this - I’d be happy to know about it.  It would be a good feature for future versions - Even given the current database design where each new custom field is a real field in the entries_data table (which I still don’t understand.. ), it should be possible with relatively minor modifications to allow users to reuse the fields for multiple field groups.  It could even be a simple extension - but I’m too new to EE to attempt it at this point.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases