SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: Help with db layout
-
Mar 30, 2002, 15:30 #1
- Join Date
- Mar 2002
- Location
- Los Angeles
- Posts
- 325
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Help with db layout
Hey,
I am geting started on my first real database project, and I have a couple of questions.
I am making a table for articles in a magazine. My question is, concerning the images that accompnay a story, should I use a difernt column for each image, like image1, image2, image3, or can (or should) I put the three images in one column together? (The amount of images will probably vary with each story).
Also, I want to use the primary key from one table in this new table, so all I have to do is use the same column name right?
i am using mysql, if that makes a differenceFrom here on, it's instinctual...even straight roads meander.
-
Mar 31, 2002, 13:15 #2
- Join Date
- Mar 2002
- Location
- Osnabrück
- Posts
- 1,003
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you say the amount of images varies it is IMO best to put the images delimited by some character into one column and using PHP / Perl to display them afterwards properly.
-
Mar 31, 2002, 19:48 #3
- Join Date
- Mar 2002
- Location
- Los Angeles
- Posts
- 325
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thats what i was thinking, but how would i go about that?
From here on, it's instinctual...even straight roads meander.
-
Apr 1, 2002, 05:38 #4
- Join Date
- Nov 1999
- Location
- Mechanicsburg, PA
- Posts
- 7,294
- Mentioned
- 123 Post(s)
- Tagged
- 1 Thread(s)
Personally, I would create another table that contains the images for an article. I wouldn't put a variable field in a database, but that's just me...
Dave Maxwell - Manage Your Site Team Leader
My favorite YouTube Video! | Star Wars, Dr Suess Style
Learn how to be ready for The Forums' Move to Discourse
-
Apr 1, 2002, 19:25 #5
You can make a second table to store the pictures and a id link, for example:
First, in your main table make a id field if you don't already have one. Then make a new table to store your pictures, with each having a id number w/ the exact same id number as the corresponding entry in the main table.
So if you had a user "17", then if they wanted to have a picture you insert it into the picture table with it's link_id number also as "17". And so on. Then to select all the pictures you simply "SELECT * FROM picture WHERE link_id = 17" and you'd get a list of all the pictures.
It's fast & easy.
Owen
-
Apr 1, 2002, 21:06 #6
- Join Date
- Mar 2002
- Location
- Los Angeles
- Posts
- 325
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
yep it seems like thats the route im gonna go...with a seperate table for the images
From here on, it's instinctual...even straight roads meander.
-
Apr 2, 2002, 07:09 #7
db normalization..
read a little bit on database normalization on devshed.com (under mysql)
it will make it much simpler to create a well planned db that way.Rahul Singh, CEO
http://www.anant.us
http://www.anant.us/blog/
http://community.rainbowportal.net/
Bookmarks