Sym Links ... For Databases ?

Status
Not open for further replies.

Enigmabomb

New member
Feb 26, 2007
2,035
66
0
Than Franthithco
I have a huge database table. It's a products table for a website that has 100k products. I've been charged with duplicating the website, under a different brand. Since the database is constantly updated with stock, and price info, is there a way I can "sym link" to it from my other database?

Ideally, I'd use the same table.

Thanks

Josh
 


Just use the same database and just call it from the new site. If it's on a different server just change the hostname in your config (from localhost to db01.yourdomain.com or whatever). Unless I am reading your question wrong.
 
I have a huge database table. It's a products table for a website that has 100k products. I've been charged with duplicating the website, under a different brand. Since the database is constantly updated with stock, and price info, is there a way I can "sym link" to it from my other database?

Ideally, I'd use the same table.

Thanks

Josh

Not exactly sure what you mean, but if you mean you want to move this database to a new database then just do a dump and re-upload to the new one.
 
Im describing this poorly. Thanks for your answers, let me see if I can be more clear.

Every hour, a program updates a table of 100k items in a datbase for one shopping cart. I want to make a duplicate cart, with a duplicate products table.

This is in a shopping cart, and it needs it's own copy of the products table, there is way too much code to change to make it look for a separate table. The other thing is, How feasible is it to copy over this table every half hour or so? Just make it a cron job? That'd be the easier answer.

Josh
 
You could use triggers to update your second table any time the first one is changed. Both tables need to have the same structure and primary key. For example, if the primary key field is called pKey, you would create these triggers to keep the tables synchronized:

create procedure copy_row(uid int)
begin
INSERT INTO table2 (pKey,field1,field2)
SELECT pKey,field1,field2 from table1 WHERE pKey = uid;
end;

--INSERT TRIGGER--

create trigger table1_ins AFTER insert on table1
for each row begin
call copy_row(NEW.pKey);
end;

--UPDATE TRIGGER--

create trigger table1_upd AFTER update on table1
for each row begin
call copy_row(NEW.pKey);
end;

--DELETE TRIGGER--

create trigger table1_del AFTER delete on table1
for each row begin
delete from table2 WHERE pKey = OLD.pKey;
end;
 
  • Like
Reactions: Enigmabomb
Status
Not open for further replies.