Square wheels

gav on 2007-06-19T02:33:50

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)




hm?

slanning on 2007-06-19T10:27:42

I wish I knew what you were talking about. :)

Could be worse ...

fansipans on 2007-06-19T14:03:17

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)
bit_sequence_member(sequence_id,bit_id,ordinal)


Maybe your tables are just views over bit and bit_sequence ...

This is sometimes a workaround for other problems

btilly on 2007-06-19T16:59:07

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 didn't have the common sense to understand why it is a bad idea.

I've always thought of it as ...

derby on 2007-06-19T18:15:29

... a real bad case of premature generalization

It's the Inner-Platform Effect

Phred on 2007-06-19T19:41:55

Inner-Platform Effect

All tables in one table

Ron Savage on 2007-06-21T01:03:32

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 :-(.