Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-21-2007, 06:09 PM   #1
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
[BIZ] Database designers.. what's the best way to.....

Set up multiple databases and scripts to use some common data. For example, let's say I have a bunch of different scripts (that should/could be standalone), but they all need some of the same data.. plus they can all add to that data... eg: let's say I'm storing a bunch of domains.. Multiple scripts (Traffic trading, TGP, Thumb etc.) on multiple sites need to read and write to "a" list of domains. Ideally I want it to be the same list so I have one central comprehensive listing.

Should that data be in it's own DB and all the scripts take the extra connection hit to access it and write to it and also lose the ability to perform queries by joining that data with other data in the script specific DB?

Should each script have it's own copy of the data and when a particular script adds a new piece of data it does it to all of the other DBs at the same time?

Is there a better option? Any ways to make these options more efficient?

I'm using MySQL.
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2007, 06:25 PM   #2
dozey
Confirmed User
 
dozey's Avatar
 
Join Date: Nov 2004
Location: Moonland
Posts: 552
Could use replication, though it may not always be up to date.. and I imagine you will lose some transaction locking ability.
dozey is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2007, 06:27 PM   #3
Varius
Confirmed User
 
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
Will it be on the same server? If so, you can have different databases and access them without opening new connections. Cross-database joins also work fine in mysql.

Example:

you create three databases: common, site1, site2

You can do queries such as:

SELECT a.field1, a.field2, b.field2 FROM site1.table1 a JOIN common.table1 b ON a.field1=b.field1;

Basically, in your queries that use more than one database just have the dbname in the query before the table name.

Hope that answers your question.
__________________
Skype variuscr - Email varius AT gmail
Varius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2007, 06:29 PM   #4
Sansa
Confirmed User
 
Join Date: Apr 2007
Posts: 293
I see nothing wrong with using one database and have scripts connect to it. Make sure your scripts use persistent connections and if you're doing a lot of updates make sure to use InnoDB instead of INNODB table type. Also make sure to set up your primary keys and indeces. If you're doing lots of updates the table should have a numeric primary key (auto_increment) and do updates based on the primary key.
Sansa is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2007, 06:39 PM   #5
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Quote:
Originally Posted by Varius View Post
Will it be on the same server? If so, you can have different databases and access them without opening new connections. Cross-database joins also work fine in mysql.

Example:

you create three databases: common, site1, site2

You can do queries such as:

SELECT a.field1, a.field2, b.field2 FROM site1.table1 a JOIN common.table1 b ON a.field1=b.field1;

Basically, in your queries that use more than one database just have the dbname in the query before the table name.

Hope that answers your question.
I've never tried cross database joins.. I'll have to give that a go as that would work very nicely. How do you handle the DB connections in this case? Which linkid would you use?
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2007, 06:40 PM   #6
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Quote:
Originally Posted by Sansa View Post
...make sure to use InnoDB instead of INNODB table type...
What are the benifits/drawbacks to InnoDb instead of INNODB?

I pretty much always use auto_increment primary key Ids in my tables.
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2007, 06:44 PM   #7
Varius
Confirmed User
 
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
Quote:
Originally Posted by Tempest View Post
I've never tried cross database joins.. I'll have to give that a go as that would work very nicely. How do you handle the DB connections in this case? Which linkid would you use?
Open your connection to any of the database names, doesn't matter. Or none at all even like this with native php mysql functions:

$sock = mysql_connect('host','user','pass');
$sql = "whatever";
$res = mysql_query($sql,$sock);

In that case though you must make sure your query specifies the db name, otherwise you'd get an error.
__________________
Skype variuscr - Email varius AT gmail
Varius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2007, 06:46 PM   #8
Varius
Confirmed User
 
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
Quote:
Originally Posted by Tempest View Post
What are the benifits/drawbacks to InnoDb instead of INNODB?

I pretty much always use auto_increment primary key Ids in my tables.
For rows that change often or for big tables use InnoDB. For reference tables, that say have few rows that never change, choose INNODB.

Best you check mysql.com for full comparisons between all engine types though.
__________________
Skype variuscr - Email varius AT gmail
Varius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-21-2007, 07:09 PM   #9
chuvii
Confirmed User
 
Join Date: Sep 2006
Posts: 691
create more databases
or tables
__________________
Mainstream and Adult Design
chuvii is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.