whiteboikyle Posted June 23, 2011 Share Posted June 23, 2011 I was thinking of coding a site similar to facebook/myspace.. my question is where to start with my database.. Now i know how to code. Im just looking for the fastest, efficient way.. for example photos do i make 1 table by photos and label each image by the USERID then do a query to find all images by that user.. To me that seems alot of work to do. I feel it would be easier to create a table for each user. But then the space for that sql would be huge.. If you can point me in the right direction that would be great Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/ Share on other sites More sharing options...
loudog Posted June 24, 2011 Share Posted June 24, 2011 The funny thing is that in the internet course i took for php that was the project. we did the following things of course u still have to valid it them with php or javascript and inserting the values into my sql. If you don't know what to put for info you could always copy the reg and log in page from facebook. 1 registration page. 2 log in page 3 profile page.(In that page is where you upload you're pics) 4 add and delete friends page 5 changing ur password page. Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/#findComment-1234149 Share on other sites More sharing options...
QuickOldCar Posted June 25, 2011 Share Posted June 25, 2011 About the images per user. It's best to have a central folder or can also do username folders to store all the images. When the image is uploaded, add a timestamp to the image name (to make every image unique even if named the same), save that image name/location to a database along with their user id. There are also more advantages for storing them in a database. You can add custom titles, description, uploaded date, ratings, public or private and so on. here's an example of my insert query mysql_query("INSERT INTO user_image (user_id, rank, public_view, title, description, upload_date, type, size, file_location) VALUES ('$user_id', '$rank', '$public_view', '$escaped_title', '$escaped_description', '$my_date', '$file_type', '$file_size', '$final_file_location')"); Basically if the user was to have only one image, i can see you just using a user table and add their image. But if the user is to have more than one image or a gallery, make an exclusive images table. Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/#findComment-1234551 Share on other sites More sharing options...
whiteboikyle Posted June 25, 2011 Author Share Posted June 25, 2011 About the images per user. It's best to have a central folder or can also do username folders to store all the images. When the image is uploaded, add a timestamp to the image name (to make every image unique even if named the same), save that image name/location to a database along with their user id. There are also more advantages for storing them in a database. You can add custom titles, description, uploaded date, ratings, public or private and so on. here's an example of my insert query mysql_query("INSERT INTO user_image (user_id, rank, public_view, title, description, upload_date, type, size, file_location) VALUES ('$user_id', '$rank', '$public_view', '$escaped_title', '$escaped_description', '$my_date', '$file_type', '$file_size', '$final_file_location')"); Basically if the user was to have only one image, i can see you just using a user table and add their image. But if the user is to have more than one image or a gallery, make an exclusive images table. by that you mean a SQL for every user created? Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/#findComment-1234604 Share on other sites More sharing options...
QuickOldCar Posted June 25, 2011 Share Posted June 25, 2011 have a single table just for images in database save all images to same folder on upload insert image_name/location and also user_id into mysql and use auto_increment for id I mention the use of id because if they marked an image as public..you could make an images gallery of all the users, or per user. You are most likely going to have a users table to store items like username,email,password,join_date and so on. Since there is no need to find all their images everywhere they go on the site...while still retaining their user info and avatar, you could also just add something like an avatar_photo to the users table, and insert the location where the avatar is stored. That location could also be an external web address if desired. If they never select an avatar have a default image to be used. I personally created a thumbnailer for the images to use as avatars with GD each of the values can be manipulated on the fly to see different results here's an example http://get.blogdns.com/dynaindex/thumb-create.php?size=100&rotate=0&text=Quickie&textsize=6&textcolor=aqua&crop=1.1&bordermargin=0&borderwidth=2&bordercolor=silver&imgsource=http://get.blogdns.com/dynaindex/images/1297191972-09l.jpg and this is the original uploaded image http://get.blogdns.com/dynaindex/images/1297191972-09l.jpg Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/#findComment-1234614 Share on other sites More sharing options...
whiteboikyle Posted June 25, 2011 Author Share Posted June 25, 2011 have a single table just for images in database save all images to same folder on upload insert image_name/location and also user_id into mysql and use auto_increment for id I mention the use of id because if they marked an image as public..you could make an images gallery of all the users, or per user. You are most likely going to have a users table to store items like username,email,password,join_date and so on. Since there is no need to find all their images everywhere they go on the site...while still retaining their user info and avatar, you could also just add something like an avatar_photo to the users table, and insert the location where the avatar is stored. That location could also be an external web address if desired. If they never select an avatar have a default image to be used. I personally created a thumbnailer for the images to use as avatars with GD each of the values can be manipulated on the fly to see different results here's an example http://get.blogdns.com/dynaindex/thumb-create.php?size=100&rotate=0&text=Quickie&textsize=6&textcolor=aqua&crop=1.1&bordermargin=0&borderwidth=2&bordercolor=silver&imgsource=http://get.blogdns.com/dynaindex/images/1297191972-09l.jpg and this is the original uploaded image http://get.blogdns.com/dynaindex/images/1297191972-09l.jpg i was definitly thinking this at the begining but if i had a 100 million user website wouldnt that load really slow? Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/#findComment-1234779 Share on other sites More sharing options...
QuickOldCar Posted June 25, 2011 Share Posted June 25, 2011 If you get to 100 million users , you could pay people to figure it all out and be across multiple servers. create indexes in mysql save and cache the output gd images cache queries, pages I believe it would be slow using a single database no matter how you did it if had many users. I was planning to do my users areas designed something like this, main site with registration and login mysql to keep track of users, id, user page, avatar, join date, tagged/keyword interests new registrations creates a new folder with username in username folder...premade sqlite databases for each user... posts, friends, comments, images have a selection of different community themes for them but no editing allowed Might as well tell you about cassandra. http://cassandra.apache.org/ Cassandra is in use at Digg, Facebook, Twitter, Reddit, Rackspace, Cloudkick, Cisco, SimpleGeo, Ooyala, OpenX, and more companies that have large, active data sets. The largest production cluster has over 100 TB of data in over 150 machines. Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/#findComment-1234785 Share on other sites More sharing options...
whiteboikyle Posted June 25, 2011 Author Share Posted June 25, 2011 Ive never messed with SQL lite.. Is it a form of XML database installed in that folder? Any tutorials on it? Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/#findComment-1234789 Share on other sites More sharing options...
QuickOldCar Posted June 25, 2011 Share Posted June 25, 2011 http://www.sqlite.org/ http://php.net/manual/en/ref.pdo-sqlite.php http://zetcode.com/databases/sqlitetutorial/ http://www.djhweb.co.uk/sqlite1.htm That should get you started. Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/#findComment-1234794 Share on other sites More sharing options...
whiteboikyle Posted June 25, 2011 Author Share Posted June 25, 2011 I have a shared hosting can i use sqllite if they dont have it installed on a server or ?? Quote Link to comment https://forums.phpfreaks.com/topic/240251-where-to-start-help/#findComment-1234826 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.