id = int
type = int
name = char (20?)
desc = char (255?)

ID will be primary key and auto increment, so you don't have to worry about duplicate IDs. Type will be int, since mySQL uses int space for bools anyway, and you might want other types in the table (flagged for checking, flagged for delete, etc). Name will be whatever the max size of your words is. Desc will be the max size of your descriptions. You can use different field names if name and type give errors, and aliases will have ID-delimiter-name in the desc field.

Yes, this does make for potential problems if you remove a word and forget to also remove all aliases pointing to it, but a simple DELETE FROM table WHERE desc = 'ID-delimiter-name' will fix that. Just do it before you delete the word, NOT after. The only downside is that your aliases take up extra space (description length minus alias info length), but then again, you only have to do one query per word access, not two (if you have aliases or descriptions in a separate table), and you don't have fields that aren't being used (if you keep alias info separate from description field in the same table). Alias deletion itself does not have to be efficient, since you will hardly ever delete words.


In reply to Re: OT: benefits of database normalization by TedPride
in thread OT: benefits of database normalization by revdiablo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.