MySQL Foreign Key Lookup

If you’ve ever found yourself trying to determine which tables have a foreign key to a given table in MySQL the following query should do the trick.

Variables:

  • MY_SCHEMA – name of schema the referenced table is in
  • MY_TABLE – name of the table being referenced by foreign keys

Query:

SELECT
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME,
REFERENCED_COLUMN_NAME
FROM
information_schema.KEY_COLUMN_USAGE
WHERE
REFERENCED_TABLE_SCHEMA = 'MY_SCHEMA'  AND
REFERENCED_TABLE_NAME = 'MY_TABLE';

Settling in San Francisco

So I’ve officially moved to San Francisco and started working at the [new job](http://www.structuralwealth.com). I’m living in the in a place called Marina Cove which will be home for at least the next few months while I get my bearings and a better idea of where I’d like to be long term. The marina area is nice, right by the bay, beach, presidio and a few other parks but the general crowd might a bit too fratboy for me. On the plus side I live right next to the area’s Safeway grocery store so not having a car hasn’t been a big issue and eating well is easy. Also the 30x express bus stop is two blocks away and gets me to work in under 15 min.

More to come about SF

How to create a Dub style heavy rotation smart playlist in iTunes

Let’s face it, you know what songs you’re listening to a lot but what if you wanted a playlist that gave this information to you so you could say blog about which songs are on your own personal top 10 list. My goal was to create a playlist which will show me that songs I listened to the most in the last week that I’ve recently added to my collection. This isn’t really possible in iTunes smart playlists since the play count doesn’t actually store the dates of each time you listen.

That said, here’s a set of rules that gets pretty close:

1. Last Played – is in the last – 7 days
2. Date Added – is in the last – 1 months
3. Rating – is greater than – (no stars)

Then to get my top X songs I just order by rating.

I’m sure I could improve on this and would be interested to hear about your creative playlist ideas.

Dub’s Heavy Rotation 1 – ‘New Magnetic Wonder’


Music is a very large part of my life and my typical work day. I’ve been thinking for some time now how to share what I listen to with you. I’ve thought about podcasting but figured it’d be hard to keep that commitment up, plus I’d want to play tons of copy-written material. I’ve thought about doing album reviews but there are so many people far more eloquent who do a better job. Instead, for now, I’m going to simply post songs/albums/artists that are in my [heavy rotation play list](http://www.jontodd.com/2008/04/17/how-to-create-a-dub-style-heavy-rotation-smart-playlist-in-itunes/). I’m doing this to hopefully start some dialog and learn about great new music from you.

So for the first installment I bring you [Apples in stereo’s](http://www.applesinstereo.com/) latest album New Magnetic Wonder. My favorite 4 song on the album in order of awesomeness:

  1. Same Old Drag
  2. Energy
  3. Sunndal Song
  4. 7 Stars

Visit their website to give the songs a listen.