Re: [PHP] help me in creating tables on the fly

2005-10-12 Thread Jochem Maas

Suresh Pandian wrote:

hello friends,
 
im currently working on creating musical forum.

i need to create tables for every song uploaded on the fly to save the comments 
and rates entered by the viewers.
im unable to create tables on the fly.


...

if I upload 1000 songs to your server then that will ammount to a 1000 tables. 
and a 1000
songs is nothing the whole idea of creating a table for every song is wrong 
and will get you
into trouble (100,000 songs will crash your system), you only need one table to 
store
all the comments for each song - and possible one extra table to store the 
rates for all songs.


can anyone know how to create tables on the fly .plz tell me .


all you need to do is generate an sql query with the CREATE TABLE syntax. and 
then run it
the same way you would run a normal query - thsi assumes that youre database 
actually allows
the relevant user to create tables.


Also, can u tell me the way to how to play the song using php..
i uploaded the songs to mysql database...
if u know the same kind of work  anywhere  in the net as tutorials and help 
.plza tell me the URL


Google for 'Database design' 'Data Normalization' and stuff like that - you 
seem to be in need
of knowledge regarding how to create a half decent database (one that wont bite 
you in the ass)

 
Thanks to all..
 
Suresh.P



-
 Yahoo! India Matrimony: Find your partner now.


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



Re: [PHP] help me in creating tables on the fly

2005-10-12 Thread Jasper Bryant-Greene

Suresh Pandian wrote:

im currently working on creating musical forum. i need to create
tables for every song uploaded on the fly to save the comments and
rates entered by the viewers. im unable to create tables on the
fly. can anyone know how to create tables on the fly
.plz tell me . Also, can u tell me the way to how to
play the song using php.. i uploaded the songs to mysql
database... if u know the same kind of work  anywhere  in the net as
tutorials and help .plza tell me the URL


AHHH! Don't create a table for every song Have a `songs` table 
containing all of the songs. Something like:


CREATE TABLE songs (songID INT UNSIGNED NOT NULL AUTO_INCREMENT, artist 
VARCHAR(50) NOT NULL, title VARCHAR(50) NOT NULL, PRIMARY KEY(songID));


(simplified) and another table `comments` like this:

CREATE TABLE comments (commentID INT UNSIGNED NOT NULL AUTO_INCREMENT, 
songID INT UNSIGNED NOT NULL, comment TEXT NOT NULL, PRIMARY 
KEY(commentID), KEY(songID));


and another `ratings` like this:

CREATE TABLE ratings (ratingID INT UNSIGNED NOT NULL AUTO_INCREMENT, 
songID INT UNSIGNED NOT NULL, rating TINYINT UNSIGNED NOT NULL, PRIMARY 
KEY(ratingID), KEY(songID));


That's why it's called a *relational* database. If you're using InnoDB 
you can even define the relations between the tables using foreign keys. 
Go to http://dev.mysql.com/doc/en/mysql/ and have a good read of the 
MySQL manual, it will be very helpful for you.


Please don't just copy-paste the above table definitions, they're meant 
to be modified to suit your needs.


I'll leave your other question to be answered by someone with experience 
of streaming audio from PHP, as I've never had occasion to do that.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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