As long as we're able to retrieve information about a given table it would be fine I guess. A TDBSchema should contain all tables, since a schema is your database layout. Instead of always requesting the table info it could make use of some form of lazy loading. For example, a TDBSchema will cache info for all tables from a given database schema, but will only execute a query to get the table info when the user asks for it. It can then put it in a cache so the next time the data will be there.
Generally a database layout is fixed within an application and is unlikely to change during runtime. Nonetheless it would be useful to have a Reset() method to reset the complete cache and a ResetTable(tableName:String) method.
.... Just now I was writing a simple prototype to demonstrate it but as my MaxIDE under Linux crashed I lost the source. But basically, it could contain these methods.
Type TDBSchema Abstract
Field tableInfo:TMap
'Returns a TMap containing TQueryField
'Method should check if the key tableName is already
'inside the tableInfo TMap. If it isn't, it should call
'a SetTableInfo(tableName:String)
Method GetTableInfo:TMap(tableName:String) Abstract
'Set table info
'It should execute a query to retrieve table info
'about the given table. It should then add a entry into
'tableInfo with the key tableName
Method SetTableInfo(tableName:String) Abstract
'Reset given tablename
'Since there's a cache you could just remove the entry
'from the tableInfo TMap
Method ResetTable(tableName:String) Abstract
'Reset all tablenames
'Just clear the TMap
Method Reset() Abstract
End Type
I'm suggesting using TQueryField types because they look like they can contain the data. Or perhaps some other type. The data this Type should store about a column could be: data type, NULL allowed, column name, primary key?
Just some thoughts :-)