Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is what is called ORM. That is, <a href="http://en.wikipedia.org/wiki/Object-relational_mapping" rel="nofollow noreferrer">Object-relational mapping</a>. You have several ORM frameworks available for Delphi. See for instance <a href="https://stackoverflow.com/questions/422426/orm-for-delphi-win32">this SO question</a>. </p> <p>Of course, don't forget to look at our little <a href="http://blog.synopse.info/tag/mORMot" rel="nofollow noreferrer">mORMot</a> for Delphi 6 up to XE2 - it is able to connect to any database using directly OleDB (without the ADO layer) or other providers. There is a lot of documentation available (more than 600 pages), including general design and architecture aspects.</p> <p><p>For example, with mORMot, a database <code>Baby</code> Table is defined in Delphi code as: <pre><i>/// some enumeration</i> <i>// - will be written as 'Female' or 'Male' in our UI Grid</i> <i>// - will be stored as its ordinal value, i.e. 0 for sFemale, 1 for sMale</i> TSex = (sFemale, sMale);<p> <i>/// table used for the Babies queries</i> TSQLBaby = <b>class</b>(TSQLRecord) &nbsp;&nbsp;<b>private</b> &nbsp;&nbsp;&nbsp;&nbsp;fName: RawUTF8; &nbsp;&nbsp;&nbsp;&nbsp;fAddress: RawUTF8; &nbsp;&nbsp;&nbsp;&nbsp;fBirthDate: TDateTime; &nbsp;&nbsp;&nbsp;&nbsp;fSex: TSex; &nbsp;&nbsp;<b>published</b> &nbsp;&nbsp;&nbsp;&nbsp;<b>property</b> Name: RawUTF8 <b>read</b> fName <b>write</b> fName; &nbsp;&nbsp;&nbsp;&nbsp;<b>property</b> Address: RawUTF8 <b>read</b> fAddress <b>write</b> fAddress; &nbsp;&nbsp;&nbsp;&nbsp;<b>property</b> BirthDate: TDateTime <b>read</b> fBirthDate <b>write</b> fBirthDate; &nbsp;&nbsp;&nbsp;&nbsp;<b>property</b> Sex: TSex <b>read</b> fSex <b>write</b> fSex; <b>end</b>; </pre><p>By adding this <code>TSQLBaby</code> class to a <code>TSQLModel</code> instance, common for both Client and Server, the corresponding <i>Baby</i> table is created by the Framework in the database engine. Then the objects are available on both client and server side, via a RESTful link (over HTTP, using JSON for transmission). All SQL work ('<code>CREATE TABLE ...</code>') is done by the framework. Just code in Pascal, and all is done for you. Even the needed indexes will be created by the ORM. And you won't miss any ' or ; in your SQL query any more.</p> <p>My advice is not to start writing your own ORM from scratch.</p> <p>If you just want to map some DB tables with objects, you can do it easily. But the more time you'll spend on it, the more complex your solution will become, and you'll definitively reinvent the wheel! So for a small application, this is a good idea. For an application which may grow in the future, consider using an existing (and still maintained) ORM.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload