Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: OT: Data Warehousing Strategies

by Booger (Pilgrim)
on Aug 27, 2006 at 17:31 UTC ( #569886=note: print w/replies, xml ) Need Help??

in reply to Re: OT: Data Warehousing Strategies
in thread OT: Data Warehousing Strategies

We're using MySQL at the moment. I would personally prefer using PostgreSQL but the other developers aren't familiar with it and depend too highly on phpMyAdmin.

The new version of the application will run on MySQL 5 so I'll have all of its features at my disposal.

I'm a little hesitant to split into several databases (although you provide good reasons for doing so) but only because I don't know what the ramifications are when it comes to doing a select across multiple databases (something I've very rarely done). We would have to do this because we have to combine customer data quite frequently when presenting it to the end user.

Thanks for your input!

Replies are listed 'Best First'.
Re^3: OT: Data Warehousing Strategies
by roboticus (Chancellor) on Aug 28, 2006 at 01:51 UTC
    I'm not terribly familiar with MySQL. Most of my experience is with Sybase and MS SQL Server (which are very closely related). In these, you simply prefix the table name with the database name and owner to access a table in a different database. (Assuming, of course, that the login has permissions on both databases.)

    Suppose for example that you have two databases, common and cust1. The common table has table states which contains the full name of each state (full_name), keyed by its abbreviation (ST). The cust1 database has table customers which has the customer number (Cust_ID) and state (ST). If you're logged into cust1 and want to count all the customers by state and list the state name, you'd do something like this:

    select common.dbo.states.full_name, count(customers.*) from customers join common.dbo.states on customers.ST = common.dbo.states.ST group by common.dbo.states.full_name order by common.dbo.states.full_name

    So it's a bit verbose. But there's another trick you can use in these two databases: You can hide the table in the remote database behind a view so it looks just like a table in the current database. Something like this:

    create view states as select ST, full_name from common.dbo.states
    Now you can perform the previous operation more naturally:

    select states.full_name, count(customers.*) from customers join states on customers.ST = states.ST group by states.full_name order by states.full_name

    As I said earlier, I'm not very familiar with MySQL (not having used it since about v3.1), but I'd imagine that it offers similar capabilities. Hopefully a knowledgeable MySQL or PostgreSQL user will chime in with similar operations, or improved suggestions.


      What you're describing sounds right and AFAIK it's the same in MySQL as MS SQL Server & Sybase (both of which I've used as well, albeit in somewhat limited capacities). My father-in-law is a DBA for a midsized company that and does fancy DB stuff like OLAP & multi-dimensional databases. I'm going to see him this weekend at the Jersey shore and may bend his ear about it if I need to (my wife & I live in a different country so we don't get to see them very often).

      Thanks again roboticus!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://569886]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2018-05-25 00:20 GMT
Find Nodes?
    Voting Booth?