Board index » delphi » how to work with RDBMS data as with objects???

how to work with RDBMS data as with objects???

I read a lot about mapping objects into relational databases and
understood nothing :)
I think authors write not about mapping at all but about DB
normalization. I didn't find out any useful examples in those papers.
Take for example "Mapping Objects to Tables. A Pattern Language.
Wolfgang Keller. You can find it on http://www.objectarchitects.de/"
Maybe I am wrong. But I have already knew it from my DB course in
University.
But! Could someone give me any working example how to implement that
mapping!!!

I want to implement a simple thing:

I have two tables:
Folders(ID, Name) (ID and Name are attributes) and
Files(ID, Name, FolderID (foreign key) ).
One-To-Many relationship as you can see.
So I have smth like Windows Explorer has. Data is stored in two
Paradox tables for example. I would like to visualize my data the same
way as Windows Explorer does using TtreeView and TlistView. I would
like to work with my data as with objects.

I think I should create 3 objects

TExplorer with metods
.LoadData(FN : TfileName; TV: TTreeView)
.AddFolder(ParentID: Integer);
.DeleteFolder(ID : Integer);
.FindFolder(ID : Integer);

Etc. What have I probably missed???

TFolder with properties
.Name
.ID
and methods
.AddFile
.DeleteFile
.ParentFolder
.LoadFiles(FolderID: Integer) or (Folder: TFolder)???

TFile with
.ID
.Name
.FolderID
??

Etc.
sorry for syntax errors I just explain my main idea

But I still can't get the clear picture of it!!!
From what should I start??? Thank you in advance!!

P.S. Please, smone help me!!

 

Re:how to work with RDBMS data as with objects???


Quote
>> What have I probably missed???

Alexander,

you might have probably missed that (almost) nobody would persist
a tree like data structure (composite pattern) like the one you discuss
in a relational database ...

One should avoid maping such structures
in a relational database because the joins would be too inefficient
(this is very short....)

For a set of forces see
http://www.coldewey.com/publikationen/database.html#DBTechTutorial

Cheers

Wolfgang

http://www.objectarchitects.de/ObjectArchitects/orpatterns/

Re:how to work with RDBMS data as with objects???


Mr. Wolfgang,

Thank you for your answer.
I haven't even thought that I could meet you here, in this newsgroup
:).

Your white papers are very informative but it would be nice if someone
created any simplest examples according to your papers. (in VB, C++,
Delphi etc.)
There is really a lack of such examples for begginers on the internet.

Re:how to work with RDBMS data as with objects???


Quote
> Your white papers are very informative but it would be nice if someone
> created any simplest examples according to your papers. (in VB, C++,
> Delphi etc.)
> There is really a lack of such examples for begginers on the internet.

not quite ...
there's plenty of code available .. e.g. if you follow some of the
links at http://www.objectarchitects.de/ObjectArchitects/orpatterns/Appendices...

Take e.g. the Smalltalk stuff by Joe Yoder - you can also read it
without a ST background and it is a example of some simple code .. or
take ozone ... or JDO .. or ...

If you need code for the more complex mappers you need to get yourself
an
eval license of e.g. TopLink.

Besides that - today there are not many reasons to build such a tool
yourself.
You have almost no chance to be better than the tool vendor who
usually employ
very specialized teams ...

I have written such a layer in 1995 - but 2 years later products like
TopLink arrived and there was no reason to write one again. But the
patterns
in these layers kept interesting me - but just a s a private hobby.  
Every since we have used products - no more self written stuff.

Concerning VB I have heard that life is a bit "rough" - recebtly had a
news discussion and some guy said he could not find any code for VB.

Hope this helps

Cheers

Wolfgang

Other Threads