You are not logged in.
Pages: 1
Hi,
I have the following simple SQL Records:
TSQLBook = class;
TSQLAuthor = class;
TSQLLinkBookAuthor = class(TSQLRecordMany)
protected
FSource: TSQLBook;
FDest: TSQLAuthor;
published
property Source: TSQLBook read FSource write FSource;
property Dest: TSQLAuthor read FDest write FDest;
end;
TSQLBook = class(TSQLRecord)
protected
FTitle: RawUTF8;
FDesc: RawUTF8;
FAuthorList: TSQLLinkBookAuthor;
published
property Title: RawUTF8 read FTitle write FTitle;
property Desc: RawUTF8 read FDesc write FDesc;
property AuthorList: TSQLLinkBookAuthor read FAuthorList;
end;
TSQLAuthor = class(TSQLRecord)
protected
FName: RawUTF8;
FBookList: TSQLLinkBookAuthor;
published
property Name: RawUTF8 read FName write FName;
property BookList: TSQLLinkBookAuthor read FBookList;
end;
In my Domain-Classes, what type do I need to use for the links? See -->
type
TBook = class;
TAuthor = class;
TLinkBookAuthor = class(TUkiSynAutoCreateFields)
private
FSource: TBook;
FDest: TAuthor;
protected
procedure AssignTo(aDest: TSynPersistent); override;
public
constructor Create; override;
destructor Destroy; override;
published
property Source: TBook read FSource write FSource;
property Dest: TAuthor read FDest write FDest;
end;
TLinkBookAuthorObjArray = array of TLinkBookAuthor;
TBook = class(TUkiSynAutoCreateFields)
private
FTitle: RawUTF8;
FDesc: RawUTF8;
--> FAuthorList: TLinkBookAuthorObjArray;
published
property Title: RawUTF8 read FTitle write FTitle;
property Desc: RawUTF8 read FDesc write FDesc;
--> property AuthorList: TLinkBookAuthorObjArray read FAuthorList;
end;
...
Kind regards,
Daniel
Offline
DDD many-to-many mapping is indeed made with T*ObjArray - which need registration.
But they will be stored as a JSON array in the database, not a JOINed table.
DDD favors aggregates, not RDBMS and table joins.
You are starting from the DB - i.e. the TSQLRecord - which is the wrong way of doing it in DDD.
Start from the objects, define the aggregate scope, then store your aggregate as a whole.
This is how DDD works.
Offline
Pages: 1