views:

40

answers:

1

I like to normalize things the most I can in a database. This isn't obviously the best thing for performance, but it helps with flexibility, reporting, etc. I've found it hard to justify in a recent case though which has caused me to build a model that has 25 fields in it. Is this "too big"? Or, is that quite normal. Of course the obvious answer is, "Whatever works best for you scenario.", but I intend to sell the software eventually, and I want whoever buys it to like the code (pay more for it).

+4  A: 

Well, like you said: does it work in your scenario?

But to answer your question in a more appropriate way: it really depends. Since you haven't provided any information about the field you define in your model, it's hard for us to guess if it's normal.

If it really bothers you, you can try to create some extra models. For example:

class User(model):
    username = Charfield()

    # Settings for this user
    showdebug = Boolean()
    regexsearch = Boolean()
    .....
    colour = HexColor()

could become:

class UserSettings(model):
    showdebug = Boolean()
    regexsearch = Boolean()
    ......
    colour = HexColor()

class User(model):
    username = Charfield()

    settings = ForeignKey(UserSettings)
Mzialla
@Mzialla - 18 of the fields are basically permanent records. For instance: `Address` fields for a `Client` get copied to a `Ticket` because if the client changes the `Address` on file, the `Ticket` must maintain its original state), and rather than create a `TicketAddress`, etc I've been adding the fields to the `Ticket` model for simplicity and DB efficiency. Would you recommend normalization here, or would you consider it overkill?
orokusaki
It's only my humble opinion of course, but I would definitely create a `TicketAddress`. It prevents confusion among other developers (if you ever plan on hiring).
Mzialla
On top of that (I couldn't edit my message somehow): if you start to feel the boundaries of your DB, you should really start to think about caching or bypassing SQL optimization executed by your DB.
Mzialla
@Mzialla - that's what I was leaning towards, but laziness kicked in :)
orokusaki