[PHP] database design in a survey/poll system

2010-11-17 Thread 肖晗
I plan to design a small survey/poll system similar to
polldaddyhttp://polldaddy.com/
.

And I have some confusion in designing the database for the multiple/single
choice questions. Of course, it is possible to use one table to store the
question title and  another table to store the choice item(one record for
each choice item).

My main concern is that whether we can place the choices together in the
same table(and in one ) with the question title. I guess it can be faster to
read from one table than reading from two table.

And my idea is to use  a delimiter to separate the choices. And the handling
of the choices are done in the php script. But what delimiter should be
used?
Can anyone help? Thanks!


Re: [PHP] database design in a survey/poll system

2010-11-17 Thread Adam Richardson
On Wed, Nov 17, 2010 at 8:42 AM, 肖晗 xiaohan2...@gmail.com wrote:

 I plan to design a small survey/poll system similar to
 polldaddyhttp://polldaddy.com/
 .

 And I have some confusion in designing the database for the multiple/single
 choice questions. Of course, it is possible to use one table to store the
 question title and  another table to store the choice item(one record for
 each choice item).

 My main concern is that whether we can place the choices together in the
 same table(and in one ) with the question title. I guess it can be faster
 to
 read from one table than reading from two table.

 And my idea is to use  a delimiter to separate the choices. And the
 handling
 of the choices are done in the php script. But what delimiter should be
 used?
 Can anyone help? Thanks!


When you denormalize like this, it's important to make sure that you don't
need to perform more complex queries on the items (sorting, max, min, etc.),
as most DB's will outperform PHP for this type of work even if it does
require one or more table relationships.

That said, when the query needs are simple enough to merit this type of
approach, I tend to JSON-encode the data (
http://php.net/manual/en/function.json-encode.php), leaving a simple
JSON-decode operation (http://www.php.net/manual/en/function.json-decode.php)
to get the queried data back into PHP form.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] database design in a survey/poll system

2010-11-17 Thread Tamara Temple

On Nov 17, 2010, at 7:42 AM, 肖晗 wrote:


I plan to design a small survey/poll system similar to
polldaddyhttp://polldaddy.com/
.

And I have some confusion in designing the database for the multiple/ 
single
choice questions. Of course, it is possible to use one table to  
store the
question title and  another table to store the choice item(one  
record for

each choice item).


As you have a many-to-one relationship of answers to questions, two  
tables would be necessary in a normalized database.


My main concern is that whether we can place the choices together in  
the
same table(and in one ) with the question title. I guess it can be  
faster to

read from one table than reading from two table.


It is possible, but really, why bother? It's not a very time consuming  
function whether you join two tables or read from one and end up  
parsing the results. String parsing can be expensive, too.


And my idea is to use  a delimiter to separate the choices. And the  
handling
of the choices are done in the php script. But what delimiter should  
be

used?


You can easily choose any character and just make sure your responses  
never include that character, or escape it somehow (eg. via \ )



Can anyone help? Thanks!


I really don't think you gain much, if anything, by having a single  
table in this instance. The retrieval is trivial for the sql engine,  
vs creating parsing code in PHP which may be trouble-prone or  
convoluted.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Database design

2010-02-24 Thread Angus Mann
Hi all. I know this is not strictly a PHP question but the code will be written 
in PHP, and I figure the folks here will be well versed in the questions I 
raise. Please feel free to contact me off the list if appropriate.

I need some assistance with database design for a project I'm coding in PHP. 
I'm willing to pay for the advice, since I think it will be a bit complex. I 
plan to use MySQLi

If anybody feels they can assist, or can point elsewhere please feel free to 
contact me off list, or reply to the list if you think appropriate.

Thanks,
Angus

Re: [PHP] Database design

2010-02-24 Thread Paul M Foster
On Thu, Feb 25, 2010 at 03:37:38PM +1000, Angus Mann wrote:

 Hi all. I know this is not strictly a PHP question but the code will be 
 written in PHP, and I figure the folks here will be well versed in the 
 questions I raise. Please feel free to contact me off the list if appropriate.
 
 I need some assistance with database design for a project I'm coding in PHP. 
 I'm willing to pay for the advice, since I think it will be a bit complex. I 
 plan to use MySQLi

Not sure why you want to use MySQLi, but I would suggest using PDO
functions instead. Either way, I'd design a wrapper class around
whatever library you use, to simplify error trapping, make the interface
simpler and more orthogonal, and improve portability. I've never
understood why they didn't provide such an overall wrapper class for the
PDO library. Having three separate PDO classes only complicates the
interface to the library.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] database design tool

2008-02-14 Thread Dax Solomon Umaming
 On Feb 12, 2008 7:46 PM, Shawn McKenzie [EMAIL PROTECTED] wrote:
 Can anyone recommend a preferably visual DB design tool? I normally use
 mysql, but one that covered several types wood be cool.  I'm on Linux,
 so the new mysql workbench is a dud.  I used it in an alpha or prior
 version and it looked promising but crashed frequently.  They say a
 Linux version in 2008, but I'm not holding my breath.

Try DBDesigner4[1], MySQL based their workbench from DBDesigner. However, 
it won't allow you to connect to MySQL5 and sync your changes, but hey, 
you're looking for a graphical designer - and this tool is great for 
designing your DBs.

You can install from source and tweak it a bit or you can install the 
win32 binary and let it run via wine (which works really well).

[1] fabforce.net/dbdesigner4/
-- 
Dax Solomon Umaming
http://knightlust.com/
GPG: 0x715C3547


signature.asc
Description: This is a digitally signed message part.


Re: [PHP] database design tool

2008-02-13 Thread Daniel Brown
On Feb 12, 2008 7:46 PM, Shawn McKenzie [EMAIL PROTECTED] wrote:
 Can anyone recommend a preferably visual DB design tool? I normally use
 mysql, but one that covered several types wood be cool.  I'm on Linux,
 so the new mysql workbench is a dud.  I used it in an alpha or prior
 version and it looked promising but crashed frequently.  They say a
 Linux version in 2008, but I'm not holding my breath.

For RAD-style database design, check out OpenOffice.org Base.  I
know it comes pre-packaged with Mandriva (which I use), but I'm not
certain about other distros.  Depending on your flavor, you can
probably apt-get, yum, urpmi, or manually install from an RPM or DEB.

It works a lot like Filemaker and Access, so if you're familiar
with those, you should notice a lot of similarities.  Plus, it will
work without a problem with MyODBC, Unix ODBC, JDBC, and native
connections.

For future reference though, Shawn, try sending to the PHP-DB list
when asking questions like that.  Then it's not off-topic.  ;-)

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] database design tool

2008-02-13 Thread Shawn McKenzie
Thanks.  I use kubuntu and have all ooo including base, but it seems
very minimal.  I connected via jdbc (as only other option is odbc for
mysql).  I can't even see how to define a key as auto increment, there
is no option.  I tried dbdesigner4 and it is very old and buggy on
linux.  I found a post that suggested I download the windows version and
run it under wine.  Works great.

As for the OT, many apologies, I never even thought of looking for a
php-db list, thanks for the heads-up.

-Shawn

Thanks!
-Shawn

Daniel Brown wrote:
 On Feb 12, 2008 7:46 PM, Shawn McKenzie [EMAIL PROTECTED] wrote:
   
 Can anyone recommend a preferably visual DB design tool? I normally use
 mysql, but one that covered several types wood be cool.  I'm on Linux,
 so the new mysql workbench is a dud.  I used it in an alpha or prior
 version and it looked promising but crashed frequently.  They say a
 Linux version in 2008, but I'm not holding my breath.
 

 For RAD-style database design, check out OpenOffice.org Base.  I
 know it comes pre-packaged with Mandriva (which I use), but I'm not
 certain about other distros.  Depending on your flavor, you can
 probably apt-get, yum, urpmi, or manually install from an RPM or DEB.

 It works a lot like Filemaker and Access, so if you're familiar
 with those, you should notice a lot of similarities.  Plus, it will
 work without a problem with MyODBC, Unix ODBC, JDBC, and native
 connections.

 For future reference though, Shawn, try sending to the PHP-DB list
 when asking questions like that.  Then it's not off-topic.  ;-)

   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] database design tool

2008-02-12 Thread Shawn McKenzie
Can anyone recommend a preferably visual DB design tool? I normally use
mysql, but one that covered several types wood be cool.  I'm on Linux,
so the new mysql workbench is a dud.  I used it in an alpha or prior
version and it looked promising but crashed frequently.  They say a
Linux version in 2008, but I'm not holding my breath.

Thanks!
-Shawn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Database design/relationship basics book

2001-11-16 Thread Dan McCullough

Does anyone have some recommendations for database books.  This is something that I 
want to get
better versed in as I have gotten along by visualizing the database and its 
relationship for small
projects, but I think I need a better base and more knowledge.  Recommendations can 
before both
MySQL specific, a query book and a database in general, please I have done database 
designs for
small projects by trial and error and extending original schemas, I would like to 
learn to do it
right the first time.  So any suggestions will help.

thanks in advance

dan

__
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]