List:General Discussion« Previous MessageNext Message »
From:J S Date:June 13 2004 4:29pm
Subject:Re: load data into 2 tables and set id
View as plain text  

>
>
>Mos forgot to populate the url_id column in your user table. I would use
>his same process but re-arrange it like this:
>
>1) create table BIG_TABLE....
>2) load data infile....
>3) create table URL_TABLE (
>       url_id bigint not null auto_increment,
>       url varchar(25) not null primary key,
>       category ....
>       )
>4) INSERT IGNORE URL_TABLE (url, category)
>       SELECT url,category
>       FROM BIG_TABLE
>4) create table USER_TABLE (
>       user_id varchar?(...) primary key,
>       date_time datetime,
>       url_id bigint,
>       size int
>       )
>
>5) insert USER_TABLE
>       SELECT bt.userID, bt.datetime, u.url_id, bt.size
>       FROM BIG_TABLE bt
>       INNER JOIN URL_TABLE u
>       ON u.url = bt.url
>
>doing it this way lets the SQL engine handle the conversion of URLs to
>their IDs in the USER_TABLE...see? No scripting required at all!
>
>Yours,
>Shawn Green
>Database Administrator
>Unimin Corporation - Spruce Pine
>
>

Shawn,

Many thanks for your reply. It sounds like this might be quicker than my 
perl script which parses a 1GB log file and fills the database in 40 mins at 
the mo. (The actual parsing only takes 1.5 mins).
There's one snag which I forgot about and that's in the url_table I have 
another column called hits which is the number of hits for each url.  I'm 
terrible at SQL and wondered if you might be able to suggest a way of doing 
this with the method above?

Thanks,

JS.

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

Thread
load data into 2 tables and set idJ S9 Jun
  • Re: load data into 2 tables and set idWilliam R. Mussatto9 Jun
  • Re: load data into 2 tables and set idmos9 Jun
Re: load data into 2 tables and set idJ S9 Jun
  • Re: load data into 2 tables and set idWilliam R. Mussatto9 Jun
Re: load data into 2 tables and set idJ S10 Jun
Re: load data into 2 tables and set idSGreen10 Jun
Re: load data into 2 tables and set idJ S18 Jun
Re: load data into 2 tables and set idSGreen18 Jun
Re: load data into 2 tables and set idJ S18 Jun
Re: load data into 2 tables and set idSGreen18 Jun
Re: load data into 2 tables and set idJ S18 Jun
Re: load data into 2 tables and set idSGreen18 Jun
Re: load data into 2 tables and set idJ S22 Jun
Re: load data into 2 tables and set idJ S22 Jun
Re: load data into 2 tables and set idJ S22 Jun
Re: load data into 2 tables and set idSGreen22 Jun
Re: load data into 2 tables and set idJ S22 Jun
Re: load data into 2 tables and set idJ S23 Jun
Re: load data into 2 tables and set idSGreen23 Jun
Re: load data into 2 tables and set idJ S23 Jun
  • Re: load data into 2 tables and set idMichael Stassen23 Jun
Re: load data into 2 tables and set idSGreen23 Jun
Re: load data into 2 tables and set idJ S23 Jun
Re: load data into 2 tables and set idSGreen23 Jun
Re: load data into 2 tables and set idJ S26 Jun
Re: load data into 2 tables and set idJ S26 Jun