Well, from a RDBMS point of view, I think that a correct structure will be something like :
A first table, ENTRY_T, with those columns :
DN : varchar (but may be an id, which will refer to another table)
ATTR : attribute name, varchar
and an ATTRIBUTES_T table :
DN : varchar
ATTR : varchar
VALUE : blob
The idea is that yoiu will set index on those table, so you don't need anymore to declare NDN.
For instance, if you want to get all attribute values for an entry, then the request will looks like :
select DN, ATTR, VALUES from ATTRIBUTES_T where DN = %dn%
(%dn% stand for the DN you are looking for)
Now, if you want all the entries which cn = ACME, the request will be :
select DN, ATTR, VALUES from ATTRIBUTES_T where DN in (select DN from ATTRIBUTES_T where ATTR = 'cn' and VALUE = 'ACME')
Just set the correct index to have good performances !
(this is just a first approach, we need to improve it a _lot_)
I have put some thought related to backend organization here : http://docs.safehaus.org/display/APACHEDS/Backend
but it needs to be further a lot !