![]() |
|
XP is just a number | |
PerlMonks |
vladb's scratchpadby vladb (Vicar) |
on Jun 05, 2004 at 12:29 UTC ( #361545=scratchpad: print w/replies, xml ) | Need Help?? |
Will print first 4 sentences:
Database dillemabasically, i'm having to deal with a case where a user is presented with a set of options to select from for example, a field named 'Property ammenities' will have values such as
If client selects option 'other', he has to enter his own custom 'amenity' info. Client is allowed to enter as many custom 'other' amenities as he/she wishes. Now, the question is, what would be the best way of storing this data in the database? Previously, I'd have an amenity_types table listing all pre-defined amenities. The table would have two fields, Id and Info. Then, I'll have another table named 'user_amenity'. Which will have two fields, user_id (referencing id in the user table) and amenity_id (referencing an amenity record in the amenity_types table). However, how do I extend this design to include an option for custom user defined amenities? Adding an extra VARCHAR column to the user_amenity table doesn't sound wise to me. So, should I just add another table... Something like 'user_amenity_other' with only thse fields: user_id and Info. Notice how amenity_id has been replaced with Info. However, having two tables seems like an overkill. What if I have 5 or 6 such similar fields that a user can set from a predefined list as well as provide his custom answer? What would be the best approach? The end of times: Output:
My japh: open(I,$0);<I>;$~=$/;$/='~';$_=<I>;($/)=/(.)$~/;s/[$~~]//g;/(v)/;$-=$-[0];s;\Q$/\E;$~;g;($/,$^)=/^(.)(.)/; #% xxxxxx xx-+ xx xxx xx xx xx xx xxx xxxxx+ xx xx xxxx xxxxx ......+ #x xxxxvxxx xx xx xv xxxx x+ %+ ===== xx xx xx xx x+ =x xx xx xx xx xx ...+ #x xx xx xx xx xx xx xx xx xxx+ xxxxxx xx +x xx xx+x- xxxx xxxx ........+ #% xx xx xx xx xx xx xx x+ xx xx =+=== xx xx xxxx-xx xx =x +x xx xx xx xx ...+ #% xx xx xx -+x+ xxx+ xx xx xx xx xx x+ xx xxx+xx xx xx xxxx xx xx ....+~ for(split/$~/){s,[ $/],,g;/(.)$/;$l=$-[0];/(.)/||next;$_=chr$-+$l;$".=($1=~/$^/)?"\u$_":$_;}print$";--------------------------------- This script that I wrote here is to test the possibility of forking a child process inside CGI to handle file uploads. I was exploring a possibility of splitting the actual work to be done to write the file to the server and render html page (displaying status etc). I have also done some rough benchmarking. You can take your own measurements by studying the contents of the report.out file where I dump start time, run time for the parent process, and run time for the child process. In all cases, child process took longer to complete. However, i'm still left to test large file uploads... i'm afraid fork won't help here as the client still has to sit and wait till the browser has finished sending all of the file (it works like a pipe.. ) Actually, I have now figured that as long as I use the CGI module as is, my script will _always_ waaaait whenever the client sends me a file. There's a subroutine inside CGI which automatically reads from the pipe and into a temporary file. This is exactly the place where I think the fork should have happened. Certainly, CGI was in no business to do that. But what _I_ could do instead is override that method with my own that will do the forking and reading from the pipe. And _then_ things _should_ work fine. ;-)
Improving access to "Writeup Formatting Tips" |
|