LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-15-2009, 03:33 AM   #1
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Wink DB question...


Hi,

Good database design suggests that data should NOT be repeated across a DB system, so, the name of a product should only appear in ONE table only and a join has to link the tables in a query.

Assuming the following

Quote:
CREATE TABLE tblTags
(
ID INT( 5 ) NOT NULL ,
tagtext VARCHAR( 15 ) NOT NULL ,
PRIMARY KEY ( `ID` )
)

CREATE TABLE tblTagPos
(
ID INT( 5 ) NOT NULL ,
tagpos VARCHAR( 15 ) NOT NULL ,
PRIMARY KEY ( `ID` )
)
a select to find out where what tag is (a label on a warehousing shelve) one would use this:

Quote:
select tblTags.ID, tblTagPos.ID, tblTags.tagtext, tblTagPos.tagpos where tblTags.ID = tblTagPos.ID order by tblTag.ID
That works in a DB where the two sit in the (physically) same database, how would I do that in Java, knowing that a Connection A was set to a common database and Connection B "looks" to the actual "data" database, the tags never change, so I'd not really HAVE to copy this table to the data but leave it in the core...

Preceding the table names with the database name is a known trick to me, but that may fail, as tblTags would be in "core" and accessible via Connection A, and tblTagPos is in the "data" database and is subject to change (the positions on the shelves can change)...

It CAN be done, but (as far as I can see) it would involve two fetch runs, one to get the positions, and one to fetch the corresponding tag texts, about as efficient as a belgian politician

Hints? Tips anyone?

Tnx

Thor
 
Old 05-15-2009, 03:40 AM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766

Original Poster
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Addendum to my first post here:

I know that it is possible to link tables across databases (some "others" do can do that) - that meant creating a "symlink" from database A to database B, can mySQL do that?

That...would be T-H-E solution!!

Security permitting, of course.

Thor
 
Old 05-18-2009, 06:03 AM   #3
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
If you are using MySQL, look at the federated engine, which is available in the newest versions.

http://dev.mysql.com/doc/refman/5.1/...ge-engine.html

The symlink approach could work, but locking would be an issue. You would have to run both servers with "--external-locking" but then both would be slowed down a lot.

Last edited by Guttorm; 05-18-2009 at 06:06 AM.
 
Old 05-19-2009, 01:00 PM   #4
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766

Original Poster
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Big tnx!!

The "shared" database would be for read-out only...so locking is not that much of an issue, I guess, it just seems a bit silly to fill up several databases with identical data that only needs to take space once, and can therefore be administred centrally...

Let me have a look at the link you gave!

Grtz!

Thor
 
  


Reply

Tags
mysql, select, tables



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Two things: (Probably Simple) Grub question, and a gDesklets question Wilffo Linux - Software 3 05-20-2006 01:33 PM
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM
samba smb.config question (quick question) TheDOGG Linux - Networking 1 03-02-2004 07:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration