I would extend to Rohits idea a little to allow granularity and the ability to create dynamic search queries by creating a table structure for each field type so that I can store and index the field data natively.<div><br>
</div><div>Any queries can be slow on this type of dynamic structure, but if each form data is bound by a common header id then you can even create a view for a form data, by using a Table Select for each field..</div><div>
<br></div><div>Select</div><div><br></div><div> (select Value from IntTable where ID = @HeaderID and FieldID = @FieldID) Age, </div><div>(select value from strTable where Id = @HeaderiD and FieldID = @FieldID) Surname</div>
<div><br></div><div>from FormHeaderData where HeaderID = @HeaderID</div><div><br></div><div>The above queries can all be dynamically generated by you on each site and rebuilt as Stored Procedures for speed.</div><div><div>
<br><div class="gmail_quote">On Wed, Mar 6, 2013 at 12:45 PM, russell <span dir="ltr"><<a href="mailto:russell@belding.co.nz" target="_blank">russell@belding.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="white" lang="EN-NZ" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Rohit’s method is like one I use that allows users to “add fields”.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Users add records to an existing table. The program manages these records (so it appears to users) as if they are fields.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">The field types are important if you allow users to store data that will not fit into a fixed length field. <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I allow three data types: Text, FileNames and Memo. The first two are single lines of text of any length and the third handles multi-line data.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">All three types are stored as BLOBs in a Firebird db file.<u></u><u></u></span></p><p class="MsoNormal">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">A “con” is these fields are not easily searched … but I do not need this ability.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Best regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Russell<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> <a href="mailto:delphi-bounces@listserver.123.net.nz" target="_blank">delphi-bounces@listserver.123.net.nz</a> [mailto:<a href="mailto:delphi-bounces@listserver.123.net.nz" target="_blank">delphi-bounces@listserver.123.net.nz</a>] <b>On Behalf Of </b>Rohit Gupta<br>
<b>Sent:</b> Wednesday, 6 March 2013 11:49 a.m.<br><b>To:</b> NZ Borland Developers Group - Delphi List<br><b>Cc:</b> List NZ Borland Developers Group - Delphi<br><b>Subject:</b> Re: [DUG] Runtime user defined fields<u></u><u></u></span></p>
</div></div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">I would consider having a generic table where you soft-add the fields<br><br>Ref_Num : autoinc<br>Owner_Num : int64<br>Field_Name : string (16)<br>
Field_Type : integer // ord(TFieldType)<br>Field_Data : string (255) // store everything as string but the type above tells you what it is<br><br>This way you dont alter the database. You dont have to worry about indexes etc. Everyones database is the same. Yet you can search for data for a particular field name. I am actually using this structure in a three projects.<br>
<br>Regards<br><br>Rohit<br><br>On 6/03/2013 10:41 a.m., Steve Peacocke wrote:<u></u><u></u></p></div><blockquote style="margin-top:5.0pt;margin-bottom:5.0pt"><pre>Hi everyone,<u></u><u></u></pre><pre><u></u> <u></u></pre>
<pre>I've been away from programming for a while so please excuse the<u></u><u></u></pre><pre>seemingly simple question.<u></u><u></u></pre><pre><u></u> <u></u></pre><pre>I'm designing a user interface for a new application and wondered if<u></u><u></u></pre>
<pre>there was a generally accepted way that this "should" be done.<u></u><u></u></pre><pre><u></u> <u></u></pre><pre>The application will allow end users to edit their forms allowing them<u></u><u></u></pre><pre>
to add, move, and remove fields at runtime. I'm using MySQL but I was<u></u><u></u></pre><pre>wondering if there was an accepted way of adding and changing fields<u></u><u></u></pre><pre>to a database.<u></u><u></u></pre>
<pre><u></u> <u></u></pre><pre>I know I can use SQL for this but I also don't want to make every<u></u><u></u></pre><pre>application unable to be managed or upgraded. Perhaps I can ensure<u></u><u></u></pre><pre>that the 3-4 permanent fields are never able to be altered (ID, Name,<u></u><u></u></pre>
<pre>etc) but allow the user (through a suitable user-friendly interface)<u></u><u></u></pre><pre>to go crazy adding such fields as My_favourite_colour, Rating,<u></u><u></u></pre><pre>Priority, Notes, etc. etc.<u></u><u></u></pre>
<pre><u></u> <u></u></pre><pre>I'm able to give a suitable user-friendly interface to allow them to<u></u><u></u></pre><pre>physically alter the Delphi form at runtime, but wondered about the<u></u><u></u></pre><pre>"most appropriate way" to modify the fields to the database.<u></u><u></u></pre>
<pre><u></u> <u></u></pre><pre>1. I could simply add fields using SQL's ALTER TABLE<u></u><u></u></pre><pre>2. I could add another table with fields such as TableName, FieldName,<u></u><u></u></pre><pre>Type, etc.. and add to that<u></u><u></u></pre>
<pre>3. Some other spiffy way that you people will suggest that I haven't<u></u><u></u></pre><pre>even thought of yet.<u></u><u></u></pre><pre><u></u> <u></u></pre><pre>Any suggestions?<u></u><u></u></pre><pre><u></u> <u></u></pre>
<pre><u></u> <u></u></pre><pre>Steve Peacocke<u></u><u></u></pre><pre>+64 220 612-611<u></u><u></u></pre><pre><a href="http://www.nzorient.co.nz" target="_blank">http://www.nzorient.co.nz</a><u></u><u></u></pre><pre>_______________________________________________<u></u><u></u></pre>
<pre>NZ Borland Developers Group - Delphi mailing list<u></u><u></u></pre><pre>Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><u></u><u></u></pre><pre>Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><u></u><u></u></pre>
<pre>Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<u></u><u></u></pre><pre><u></u> <u></u></pre><pre>
<u></u> <u></u></pre><pre>__________ Information from ESET Endpoint Antivirus, version of virus signature database 8081 (20130305) __________<u></u><u></u></pre><pre><u></u> <u></u></pre><pre>The message was checked by ESET Endpoint Antivirus.<u></u><u></u></pre>
<pre><u></u> <u></u></pre><pre><a href="http://www.eset.com" target="_blank">http://www.eset.com</a><u></u><u></u></pre><pre><u></u> <u></u></pre><pre><u></u> <u></u></pre><pre><u></u> <u></u></pre><pre><u></u> <u></u></pre>
</blockquote><p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p><div><p class="MsoNormal">-- <br>Regards<br><br><b>Rohit Gupta</b><br>B.E. Elec., M.E., Mem IEEE, Member IET<br>Technical Director<br>Computer Fanatics Ltd<br>
<br><b>Tel </b>4892280 <br><b>Fax </b>4892290 <br><b>Web </b><a href="http://www.cfl.co.nz" target="_blank">www.cfl.co.nz</a><u></u><u></u></p><div class="MsoNormal" align="center" style="text-align:center"><hr size="2" width="100%" align="center">
</div><p class="MsoNormal">This email and any attachments contain information, which is confidential and may be subject to legal privilege and copyright. If you are not the intended recipient, you must not use, distribute or copy this email or attachments. If you have received this in error, please notify us immediately by return email and then delete this email and any attachments.<u></u><u></u></p>
</div></div></div><br>_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Kyley Harris<br>
Harris Software<br>+64-21-671-821
</div></div>