Crankshaft Coalition Crankshaft Coalition  

Go Back   Crankshaft Coalition > Automotive Knowledge > Coalition Knowledge Projects > GPL Automotive Photojournal
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-07-2005, 02:12 PM
Jon Jon is offline
Hotrodders.com
 
Join Date: Apr 2005
Location: Colorado
Age: 33
Posts: 146
GPL automotive photojournal database design

With the help of Hotrodders Bulletin Board member grouch, we've come up with a rough draft of the database for our idea for a free automotive photojournal in PHP/MySQL, in this thread on the HRBB.

All code is copyright 2005 Crankshaft Coalition, and is licensed under the GNU GPL.

Here are the CREATE TABLE statements for the database.

Code:
CREATE TABLE IF NOT EXISTS journal ( userid MEDIUMINT UNSIGNED ZEROFILL NOT NULL, journalid MEDIUMINT UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY, journal_title TEXT, description TEXT, type ENUM('jpg','gif','png'), entries SMALLINT UNSIGNED DEFAULT 0, views MEDIUMINT UNSIGNED DEFAULT 0 ); CREATE TABLE IF NOT EXISTS journal_entries ( entryid MEDIUMINT UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY, journalid MEDIUMINT UNSIGNED ZEROFILL NOT NULL, date TIMESTAMP, entry_title TEXT, text TEXT, threadid MEDIUMINT UNSIGNED DEFAULT 0 ); CREATE TABLE IF NOT EXISTS journal_photos ( photoid MEDIUMINT UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY, journalid MEDIUMINT UNSIGNED ZEROFILL NOT NULL, entryid MEDIUMINT UNSIGNED NOT NULL, type ENUM('jpg','gif','png') );


We're open to any and all feedback on this.

This current database design allows for multiple photojournals per user (to record multiple hotrodding projects). However, we may not be incorporating the multiple-journal feature into the first release.

The journal photos will be stored in the filesystem, like this:

/journal_photo_directory/userid/journalid/photoid.type

Users will be able to assign a title, description, and image for each journal.

Last edited by Jon : 11-13-2005 at 07:25 PM. Reason: updated to reflect changes discussed in this thread
Reply With Quote
  #2  
Old 11-07-2005, 02:42 PM
grouch grouch is offline
Member
 
Join Date: Jun 2005
Posts: 79
Will user authentication be handled by the new journal code?
Reply With Quote
  #3  
Old 11-07-2005, 02:46 PM
Jon Jon is offline
Hotrodders.com
 
Join Date: Apr 2005
Location: Colorado
Age: 33
Posts: 146
Yes.

My thought was that we would start by emulating vBulletin authentication, and then including options for other popular forum software packages.
Reply With Quote
  #4  
Old 11-07-2005, 03:48 PM
grouch grouch is offline
Member
 
Join Date: Jun 2005
Posts: 79
Some slightly random thoughts...

* need: authentication, form for adding entries, page to display a list or summary of all journals, page to display summary of 1 journal, page to display entries of a journal

* probably should keep the page generation and the SQL work separate as much as possible, like entry_form.php and entry_form_db.php

* You mentioned elsewhere that it might be a good idea to have the comment thread starter check for a threadid one last time before commit, just in case someone started a thread while the first one was still being typed. I think that's a good idea, based on personal experience. I'm on dial-up and also kinda slow about hitting "Submit Reply" as well as being long-winded and have noticed several times that new posts were made in a thread while I was working on mine.
Reply With Quote
  #5  
Old 11-07-2005, 04:19 PM
Jon Jon is offline
Hotrodders.com
 
Join Date: Apr 2005
Location: Colorado
Age: 33
Posts: 146
We'll need a "front" page too, which will be different than the summary page. It would probably include the most recent entries, most recent photos, largest journals, etc.

We definitely need a simple journal search engine.

We'll need a method for referencing and displaying individual journal entries. That way, we can store individual entries in our Knowledge Base, or otherwise link to them, etc.

How about a few simple PHP objects to handle database connections?

A mechanism for incorporating RSS feeds will also be necessary.

Anything else you can think of?
Reply With Quote
  #6  
Old 11-08-2005, 01:21 AM
grouch grouch is offline
Member
 
Join Date: Jun 2005
Posts: 79
I'm rotten at object-oriented stuff. Right now I'm just trying to get something that works to put data in and get it back out. The exercise is showing me just how long it's been since I did anything with php.
Reply With Quote
  #7  
Old 11-08-2005, 11:01 AM
Jon Jon is offline
Hotrodders.com
 
Join Date: Apr 2005
Location: Colorado
Age: 33
Posts: 146
Quick and dirty is fine. We can always clean it up later.
Reply With Quote
  #8  
Old 11-08-2005, 04:06 PM
grouch grouch is offline
Member
 
Join Date: Jun 2005
Posts: 79
[begin edit:]
N/M. The following is just too fugly in practice. I'm leaving it here just because I don't like to delete stuff and because it might entertain.

[end edit]

"Dirty" I can do; it's the "quick" that's bogging me down. But then, all things are relative.

I know this needs to keep human readability as a higher priority than compactness or cleverness, but fetching a row as an associative array looks to be a really common thing. How about a generalized function for that? The same chores get done over and over to retrieve rows for the entry form, journal summary, journal display, etc.

(Hope the spacing and indentation holds up)

Code:
function arassoc($select,$table,$condition,$index,$order,$c ount,&$ar) { global $connection; $sql = "SELECT $select FROM $table "; if ($condition != "") { $sql .= "WHERE $condition "; } if ($index != "") { $sql .= "ORDER BY $index"; } if ($order != "") { $sql .= " $order "; } if ($count != "") { $sql .= "COUNT $count "; } connect($host,$user,$password,$db); $result = query($sql); $rows=mysql_num_rows($result); if ($rows!=0) { while ($row=mysql_fetch_assoc($result)) { $ar[]=$row; } } return $rows; }

Last edited by grouch : 11-08-2005 at 08:24 PM. Reason: second thoughts
Reply With Quote
  #9  
Old 11-09-2005, 12:20 PM
Jon Jon is offline
Hotrodders.com
 
Join Date: Apr 2005
Location: Colorado
Age: 33
Posts: 146
.

It might be best to keep the query whole, rather than dividing it up into clauses.

Try doing this with a simple database connection object.
Reply With Quote
  #10  
Old 11-09-2005, 10:04 PM
grouch grouch is offline
Member
 
Join Date: Jun 2005
Posts: 79
I just plain messed up. That happens a lot; I get started and think if this or that were changed a little, it would be much more generalized, so the whole thing becomes a generalized mess to do everything, but does nothing well. I've started over 3 or 4 times and fallen victim to that each time.

This time I will try to keep the KISS principle in mind. Simple forms, simple pages, simple queries ... and then I can make it into the Ronco Dat-O-Matic and become Supreme Evil Overlord of the Universe! Well, um, anyway, back to it.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -7. The time now is 08:16 PM.



Home  •  About  •  Join  •  Forum  •  Wiki  •  180+ Hotrodding Forums  •  Resources  •  RSS  •  Contact

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.