On Thu, 2004-12-23 at 04:27 -0500, Randall Randall wrote:
> >>
> >> Arg! Just invites people to crash your web site.
> >>
> > *their* web site... think about phpbb or similar phorums....
> 
> The unsaid part here, though quite off-topic, is that PHP bulletin
> boards are often changed with "mods" which alter the source of the
> PHP files, modify the database, etc.  The more of these you apply,
> the more likely that you've completely destroyed your installation,
> but the first few are likely to work great, and in the meantime a
> given mod can't assume that the original board's schema still applies.
> 
> I don't usually work with PHP, but a disproportionate amount of the
> time I have spent has been in applying and repairing such mods for
> clients.

No. The unsaid part is that the authors of "phpbb and similar phorums"
actually like corrupting databases and crashing web sites. I can't
believe they're stupid.

Each "mod" should create it's own tables, say:

CREATE user_birthday (username TEXT, birthday TEXT);

and then when they want to get the "email" out of the regular "user"
table, they'll want a:

SELECT username,email,birthday FROM user JOIN user_birthday USING
(username);

and be done with it. There's absolutely NO REASON WHATSOEVER for two
modules to be borking around the database.

Even if they weren't clever enough for that, they might just have a:

CREATE userdata (username TEXT, key TEXT, value TEXT);

to go ahead and treat their MySQL as the nested associated array that
they've been doing all that nasty wrapping to get this whole time.


The only times I've EVER needed an ALTER TABLE are:
* to change the "DEFAULT" of a column
* to add an additional constraint
* to remove a constraint on data I'm no longer using.

That's it. SQLite already does all of these things just fine (albeit:
with triggers).

Other "needs" for ALTER TABLE are done during development, and I have no
problem taking the database offline during development to rebuild the
schema...


So tell your friends, tell your neighbors: Stop writing stupid SQL.

Reply via email to