Jump to content

Where to start [HELP]


whiteboikyle

Recommended Posts

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

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.