Gossamer Forum
Home : Products : DBMan : Customization :

Relational Question?

Quote Reply
Relational Question?
I am working on a directory for wines and wineries and want to use the relational mod so that users can sign up and then list the wineries they own. To branch off from each winery though I also want them to be able to list wine, news and events for each of their wineries. How do I do this? Is it as simple as just having one user account and then creating a winery record and then branching off the wines, news and event db and adapting the "switch to item" "switch to user" info?

For example:

|_ user.db (the company/user)
....|_ winery.db
........|_ wines.db
........|_ news.db
........|_ events.db

Thanks a bunch Smile
Cher

Last edited by:

chronisca: Jun 22, 2004, 2:55 PM
Quote Reply
Re: [chronisca] Relational Question? In reply to
To make less databases it may be easier to combine the company/user info into one database and then have as the relational database be just users and wines.


|_ user.db (the company/user/winery)
........|_ wines.db


Are the news and events going to just be for overall information or will it be specific for each winery? If it would include all news and events they could just be separate databases.

news.db
events.db

You could provide a link with say the winery name into either of the databases to search for news or events related to that winery.

Does that make sense :)

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Relational Question? In reply to
I thought about that. The problem is that there are many companies that own many wineries and each winery produces a variety of wines originating from a select winery. You would be surprised how important the "orginating winery" information is to a wine connoisseur. For instance, Mondavi has 16 wineries located worldwide. Guess wine is big business!
Cher
Quote Reply
Re: [chronisca] Relational Question? In reply to
Quote:
Guess wine is big business!

I used to work with the Texas Wine & Grape Growers Association. They were a great bunch of folks to work with.

Sorry I didn't have any "real" input for you. Good Luck!
Quote Reply
Re: [Watts] Relational Question? In reply to
Then I think your original plan may be the best way to go :)

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [chronisca] Relational Question? In reply to
Have you thought about setting up a "home page" creator?

I used to have one on my site that allowed users to create a "home page" with up to 5 pages for each account. Perhaps this could be adapted for your use?

This way you could have 1 or 2 databases and the "news" and other items could be the home pages... It would eliminate having the whole thing database driven because I can see problems in the future with your exceeding the limits of what dbman can handle.

Just a thought...
Quote Reply
Re: [Watts] Relational Question? In reply to
I want the entire system to be database driven though. The site has to have a consistent "look and feel" to keep within corporate standards so allowing people to create their own pages doesn't meet the scope of work.
Cher
Quote Reply
Re: [LoisC] Relational Question? In reply to
That's what I thought. The only thing is that I am having a hard time what code I need to change to get the third tier database (wines.db) to relate to the second tier database (winery.db). I have read the readme file you included in the relation.zip file as follows...and I know that this should probably be modified to include the code to make all this work...I am just unsure what it is I need to change.

Any suggestions?



# Below is the only change I made to the db.cgi file, which deletes all of the "items"
# associated with a "user" when the user record is deleted.
# Note that, if you are using a file upload mod, you will need to add the code to delete
# the uploaded files as well.
# Change
$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= $line . "\n"); # otherwise print it.
# to
if ($delete_list{$data[$db_key_pos]}) { # if this id is one we want to delete
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
if ($db_setup eq 'user') {
$item_output = '';
&switch_to_winery;
open (ITEM, "<$db_file_name") or &cgierr("error in delete_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(ITEM, 1); }
@items = <ITEM>;
close ITEM;
foreach $item (@items) {
if ($item =~ /^$/) { next; }
if ($item =~ /^#/) { $item_output .= $item; next; }
chomp ($item);
@item_data= &split_decode($item);
unless ($item_data[$auth_user_field] eq $data[$db_key_pos]) {
$item_output .= $item . "\n";
}
}
open (ITEM, ">$db_file_name") or &cgierr("error in delete_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(ITEM, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print ITEM $item_output;
close ITEM; # automatically removes file lock
&switch_to_user;
}
}
else { $output .= $line . "\n"; } # otherwise print it.


Cher
Quote Reply
Re: [chronisca] Relational Question? In reply to
I'm not sure what to suggest since I'm not sure what information you are wanting to access from which database.

My suggestion would be to download the same relational mod zip file and test it out on your own server and see how everything works. There are also several examples posted in the FAQ under the sections for 'multiple' and 'relational databases'.

The great thing about looking over older posts and examples is that you can see what others have done and you wind up getting ideas you may not think of yourself while designing how you want things to work.

Since I've read almost every thread in the DBMan forums while constructing the FAQ I thought I had caught all the tricks for using the relational mod, but I found some hidden treasures in the sample mod supplied by JPDeni that was never mentioned in forum threads. There are many hidden tips and tricks in the FAQ also, you just have to take some time to explore what it has to offer under the related topics.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/