Copy link to clipboard
Copied
Hi all,
I need to figure out how to do certain things I have never tried using PHP and MySQL
Basically I am putting a site together that will need to hold information in one field.
For example, a user uploads a set of photos, but there is only one field, I know I need to create some kind of Array and explode function, but is this the best way?
Also is it better to hold the image in the database or in files on the server?
Also say if I want my user to know how many people have viewed their photos, do I add the database field in the user or photo table, and how would I append that with each view?
If someone has favourited one of my photos how can insert in to the database the number of times it has been favourited?
If I add people as my friend like in twitter or facebook how can I get a list of friends listed in the database?
I know these are really basic and silly questions.
I hope someone can point a few things out.
Thanks
>For example, a user uploads a set of photos, but there is only one field,
Why only one field? Usually, inserting more than one piece of data into a single database field is a violation of database normalization rules.
>I know I need to create some kind of Array and explode function, but is this the best way?
It depends on how you will be using the data. PHP has some pretty cool functions for handling this type of data, but nothing works as well as a properly designed database.
>Also is it better to
...Copy link to clipboard
Copied
>For example, a user uploads a set of photos, but there is only one field,
Why only one field? Usually, inserting more than one piece of data into a single database field is a violation of database normalization rules.
>I know I need to create some kind of Array and explode function, but is this the best way?
It depends on how you will be using the data. PHP has some pretty cool functions for handling this type of data, but nothing works as well as a properly designed database.
>Also is it better to hold the image in the database or in files on the server?
Store the image in the file system, not the database.
>Also say if I want my user to know how many people have viewed
>their photos, do I add the database field in the user or photo table,
>and how would I append that with each view?
If you want to track the number of total views per user, then you can store it in the user table. If you need to track views per photo, then store it in the photo table. You increment the amount using an update statement.
>If someone has favourited one of my photo...
Don't know what this means, sorry.
>I know these are really basic and silly questions.
It's good that you are asking these now. Nail down a solid database design before you start coding any of this.
Copy link to clipboard
Copied
Hi,
Thanks for your reply.
To clear a few things up:
The reason for having one field to hold all photo filenames, is because I do not know how many images the user will add.
I have the option to restrict the user to only upload say 5 images total. But I thought it would be great if they have the ability to share as much as they like.
For photo views, I am not sure how to increment the value, also say if two people look at the photo at the same time, and only one view registers. How do I manage that?
I am not a coder/developer and I keep getting stuck doing these kind of sites.
--> If someone has favourited one of my photos how can insert in to the database the number of times it has been favourited?
I think this is same as above.
--> If I add people as my friend like in twitter or facebook how can I get a list of friends listed in the database?
Say the user has added 3 people to his or her friends list, how would I create a list of their friends in the database.
Sorry I think I have figured out my last question.
forgien keys are the key.
So I would need a table for friends list that includes user_id's
Sorry for thinking on the keyboard. You have helped me, but is there any good resources available online for creating this type of site?
The site is for wedding photographers to showcase their work, and a small profile information
Copy link to clipboard
Copied
The_FedEx_Guy wrote:
The reason for having one field to hold all photo filenames, is because I do not know how many images the user will add.
To deal with this sort of situation, you need to create a linking table. Take a look at this thread from a couple of months ago: http://forums.adobe.com/message/2389270#2389270. It deals with a very similar situation, although I incorrectly refer to the structure as a "lookup table".
You need to store the details of the photos in one table, the names of the photographers in another table, and create a linking table to establish the relationship between the photographers and their photos.
I am not a coder/developer and I keep getting stuck doing these kind of sites.
If you keep getting asked to do this sort of site, you need to start learning more about the technology and design principles involved. It takes time, but it will make your life easier in the end. Database design isn't easy. A book that helped me understand the principles better is "Database Design for Mere Mortals" by Michael Hernandez. His writing style is rather verbose, but the information is basically sound and well presented.
Copy link to clipboard
Copied
>but is there any good resources available
>online for creating this type of site?
I'll just ditto David's advice and urge you to become more proficient at database design before you pursue this. I'm not familiar with the book title he suggested but it gets decent reviews at Amazon. I would also go to Amazon and search for "database design" to see if you find something that fits your learning style.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now