Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

  (email not shown publicly)
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Monday June 18, 2007
09:33 PM

Square wheels

[ #33552 ]

Why would somebody implement a database in a database? I've seen this anti-pattern a few times before and it's confusing to me, when do you wake up and say "obviously the answer is to put the data a database, but let's invent our own abstraction".

Instead of nice code that looks like:

SELECT some_value FROM some_table WHERE some_other_value = 'something';

Figure out how many SQL statements your poor database will have to execute if the schema looks like:

object(object_id, object_type)
object_type_to_attribute(object_type, attribute_id)
attribute(attribute_id, attribute_name, data_type)
table_bit(object_id, attribute_id, value)
table_string(object_id, attribute_id, value)
table_number(object_id, attribute_id, value)
table_text(object_id, attribute_id, value)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I wish I knew what you were talking about. :)
  • Actually this is pretty fancy stuff:

    object(object_id, object_type)
    object_type_to_attribute(object_type, attribute_id)

    Just be glad it's not:

    bit(bit_id, value)
    bit_sequence(sequence_id, name)

    Maybe your tables are just views over bit and bit_sequence ...
  • For instance a lot of places don't want to create or modify lots of different tables. Sometimes this is due to poor communication between programmers and DBAs, sometimes there are real problems trying to keep table definitions in sync across multiple databases. However if you can convince them to create tables like this, then those issues just magically go away.

    But, that said, it is more often a sign of a developer who heard about the fact that you can do this, the developer thought it would be cool, and
  • ... a real bad case of premature generalization
  • Yep, I've seen a RDBMS used to put all tables in one. The first column was the name of the table, so just by selecting a table name in that column, the remaining tables were 'known' so-to-say as belonging to that table. The programming language was Perl :-(.