Re: [PHP] key pairs

2002-12-17 Thread Rick Widmer
At 04:44 PM 12/17/02 -0500, 1LT John W. Holmes wrote:

What I was thinking is that you have one table with

Order_ID
Name
Address
Flag -> Here you flag this as SHIP_TO or BILL_TO
etc...


That layout would be better than:

Order_ID
Ship_name
Ship_address
Bill_name
Bill_address
etc...

Which is what I got from you last email.

Does anyone agree?


Not only do I agree, so do the people who came up with the rules of proper 
database normilization.  Here are a few of the top results on a Google 
search for database normalization.


   http://www.phpbuilder.com/columns/barry2731.php3?page=1

Watch how he handles URLs.


   http://www.devshed.com/Server_Side/MySQL/Normal

   http://www.sqlmag.com/Articles/Index.cfm?ArticleID=4887&pg=1


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] key pairs

2002-12-17 Thread Cal Evans
Possible but a single table with all addresses and an addressType (SHIP_TO
or BILL_TO) linked back to the main order table will allow you to retrieve
both addresses with a single select:

select * from address where orderID=x

=C=


*
* Cal Evans
* The Virtual CIO
* http://www.calevans.com
*


-Original Message-
From: Brad Bonkoski [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 17, 2002 3:50 PM
To: 1LT John W. Holmes
Cc: [EMAIL PROTECTED]; PHP-General List
Subject: Re: [PHP] key pairs


What about a master table like:

Order ID | Ship_TO | BILL_TO

Then an address table:
ID | NAME | ADDR | CITY | STATE | ZIP

Then you could have many addresses, and IFFthe Bill to and Ship to were the
same
then the master table would reflect that.  Many sites provide a check box to
indicate that the Bill to and Ship to are the same, which you would key off
of
and if so, assign the same Unique Address ID to both fields in the master
table.  Many ways to do this, but those are my thoughts

-Brad

"1LT John W. Holmes" wrote:

> > >Hopefully the other solution worked for how to parse the data. If not,
> post
> > >back. What I wanted to comment on is why would you use two tables, one
> for
> > >SHIP_TO and one for BILL_TO? Why not just add a column to one table set
> set
> > >it to BILL or SHIP. You won't be repeating data that way and it'll be
> easier
> > >to find things overall. Plus you can just have a column that flags
> whether
> > >the SHIP_TO and BILL_TO addresses are the same.
> > >
> > >
> > I haven't gotten that far yet.  BILL_TO and SHIP_TO aren't always
> > the same people, hence my initial thought of creating two tables and
> > keep things separate.  However, you're right, I could dump it all into
> > one table - if they're different, then populate the rest of the fields,
> > if not, don't bother.
>
> What I was thinking is that you have one table with
>
> Order_ID
> Name
> Address
> Flag -> Here you flag this as SHIP_TO or BILL_TO
> etc...
>
> Your order_ID could be a key, but it will not be unique, since if the
> bill_to and ship_to address are different, the order_id will appear in the
> table twice. So an order with different shipping and billing addresses
would
> have two rows in the table. An order where they are the same would only
have
> one row.
>
> That layout would be better than:
>
> Order_ID
> Ship_name
> Ship_address
> Bill_name
> Bill_address
> etc...
>
> Which is what I got from you last email.
>
> Does anyone agree?
>
> ---John Holmes...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] key pairs

2002-12-17 Thread Brad Bonkoski
What about a master table like:

Order ID | Ship_TO | BILL_TO

Then an address table:
ID | NAME | ADDR | CITY | STATE | ZIP

Then you could have many addresses, and IFFthe Bill to and Ship to were the same
then the master table would reflect that.  Many sites provide a check box to
indicate that the Bill to and Ship to are the same, which you would key off of
and if so, assign the same Unique Address ID to both fields in the master
table.  Many ways to do this, but those are my thoughts

-Brad

"1LT John W. Holmes" wrote:

> > >Hopefully the other solution worked for how to parse the data. If not,
> post
> > >back. What I wanted to comment on is why would you use two tables, one
> for
> > >SHIP_TO and one for BILL_TO? Why not just add a column to one table set
> set
> > >it to BILL or SHIP. You won't be repeating data that way and it'll be
> easier
> > >to find things overall. Plus you can just have a column that flags
> whether
> > >the SHIP_TO and BILL_TO addresses are the same.
> > >
> > >
> > I haven't gotten that far yet.  BILL_TO and SHIP_TO aren't always
> > the same people, hence my initial thought of creating two tables and
> > keep things separate.  However, you're right, I could dump it all into
> > one table - if they're different, then populate the rest of the fields,
> > if not, don't bother.
>
> What I was thinking is that you have one table with
>
> Order_ID
> Name
> Address
> Flag -> Here you flag this as SHIP_TO or BILL_TO
> etc...
>
> Your order_ID could be a key, but it will not be unique, since if the
> bill_to and ship_to address are different, the order_id will appear in the
> table twice. So an order with different shipping and billing addresses would
> have two rows in the table. An order where they are the same would only have
> one row.
>
> That layout would be better than:
>
> Order_ID
> Ship_name
> Ship_address
> Bill_name
> Bill_address
> etc...
>
> Which is what I got from you last email.
>
> Does anyone agree?
>
> ---John Holmes...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] key pairs

2002-12-17 Thread 1LT John W. Holmes
> >Hopefully the other solution worked for how to parse the data. If not,
post
> >back. What I wanted to comment on is why would you use two tables, one
for
> >SHIP_TO and one for BILL_TO? Why not just add a column to one table set
set
> >it to BILL or SHIP. You won't be repeating data that way and it'll be
easier
> >to find things overall. Plus you can just have a column that flags
whether
> >the SHIP_TO and BILL_TO addresses are the same.
> >
> >
> I haven't gotten that far yet.  BILL_TO and SHIP_TO aren't always
> the same people, hence my initial thought of creating two tables and
> keep things separate.  However, you're right, I could dump it all into
> one table - if they're different, then populate the rest of the fields,
> if not, don't bother.

What I was thinking is that you have one table with

Order_ID
Name
Address
Flag -> Here you flag this as SHIP_TO or BILL_TO
etc...

Your order_ID could be a key, but it will not be unique, since if the
bill_to and ship_to address are different, the order_id will appear in the
table twice. So an order with different shipping and billing addresses would
have two rows in the table. An order where they are the same would only have
one row.

That layout would be better than:

Order_ID
Ship_name
Ship_address
Bill_name
Bill_address
etc...

Which is what I got from you last email.

Does anyone agree?

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] key pairs

2002-12-17 Thread Ashley M. Kirchner
1LT John W. Holmes wrote:


Hopefully the other solution worked for how to parse the data. If not, post
back. What I wanted to comment on is why would you use two tables, one for
SHIP_TO and one for BILL_TO? Why not just add a column to one table set set
it to BILL or SHIP. You won't be repeating data that way and it'll be easier
to find things overall. Plus you can just have a column that flags whether
the SHIP_TO and BILL_TO addresses are the same.
 

   I haven't gotten that far yet.  BILL_TO and SHIP_TO aren't always 
the same people, hence my initial thought of creating two tables and 
keep things separate.  However, you're right, I could dump it all into 
one table - if they're different, then populate the rest of the fields, 
if not, don't bother.

--
W | I haven't lost my mind; it's backed up on tape somewhere.
 +
 Ashley M. Kirchner    .   303.442.6410 x130
 IT Director / SysAdmin / WebSmith . 800.441.3873 x130
 Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] key pairs

2002-12-17 Thread 1LT John W. Holmes
Hopefully the other solution worked for how to parse the data. If not, post
back. What I wanted to comment on is why would you use two tables, one for
SHIP_TO and one for BILL_TO? Why not just add a column to one table set set
it to BILL or SHIP. You won't be repeating data that way and it'll be easier
to find things overall. Plus you can just have a column that flags whether
the SHIP_TO and BILL_TO addresses are the same.

---John Holmes...

- Original Message -
From: "Ashley M. Kirchner" <[EMAIL PROTECTED]>
To: "PHP-General List" <[EMAIL PROTECTED]>
Sent: Tuesday, December 17, 2002 3:15 PM
Subject: [PHP] key pairs


>
> I have the following bit of information coming in that I need to
> generate key pairs of so I can drop it all into a database.  I'm
> creating tables for each section (SHIP_TO and BILL_TO) with matching
> Unique_IDs.  What's the best way to go about this (creating the pairs,
> stripping off excess spaces from some fields that have them after the
> last character, etc., etc.)
>
> -- data --
>   SHIP TO:
>   Business Name:
>   Contact Name: Ashley Kirchner
>   Day Number:   303 442-6410
>   Evening Number:
>   Fax Number:
>   Address:  3550 Arapahoe Ave., Ste. #6
>   Address:
>   Address:
>   City: Boulder
>   State/Province:   CO
>   Zip/Postal Code:  80303
>   Country:  USA
>
>   BILL TO:
>   Business Name:
>   Contact Name: Ashley M. Kirchner
>   Day Number:   303 4426410
>   Evening Number:
>   Fax Number:   303 442-9010
>   Address:  3550 Arapahoe Avenue
>   Address:  Suite #6
>   Address:
>   City: Boulder
>   State/Province:   CO
>   Zip/Postal Code:  80303
>   Country:  USA
> --
>
>
> --
> W | I haven't lost my mind; it's backed up on tape somewhere.
>   +
>   Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
>   IT Director / SysAdmin / WebSmith . 800.441.3873 x130
>   Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
>   http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] key pairs

2002-12-17 Thread Tim Ward
what do you mean by key pairs - I assumed you 
meant a key that could link the records in each table.
If you've already done that then what's the problem?

Tim Ward
http://www.chessish.com
mailto:[EMAIL PROTECTED]
- Original Message - 
From: Ashley M. Kirchner <[EMAIL PROTECTED]>
To: Tim Ward <[EMAIL PROTECTED]>
Cc: PHP-General List <[EMAIL PROTECTED]>
Sent: Tuesday, December 17, 2002 8:25 PM
Subject: Re: [PHP] key pairs


> Tim Ward wrote:
> 
> >1. Have an order_id on the first table (or a separate 
> >ORDER table) that is INT and AUTO_INCREMENT.
> >2. Have an order_id on the other table(s) that is INT but 
> >not AUTO_INCREMENT.
> >3. Create the record in the first table just inserting the info 
> >you get in.
> >4. get the order_id just created using mysql_insert_id().
> >5. insert the data into the other table(s) with this order_id().
> >  
> >
> Thanks, but that wasn't the question - I know this part. :)
> 
> I need a routine to run through the data and generate the key pairs 
> for insertion in the DB.
> 
> -- 
> W | I haven't lost my mind; it's backed up on tape somewhere.
>   +
>   Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
>   IT Director / SysAdmin / WebSmith . 800.441.3873 x130
>   Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
>   http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] key pairs

2002-12-17 Thread Marco Tabini
This is a bit crude but should work:



Note that I made a bunch of assumptions here--that the data is always
properly formatted, that there is only one record in the $data, and that
you will later manipulate the key names so that they will actually work
as database columns. Still, this way you can manipulate each value
directly in the function, which is something that I always find very
practical, so you can add whatever additional checks need to be
performed.

Hope this helps!

Cheers,


Marco
-- 

php|architect - The magazine for PHP Professionals
The monthly worldwide magazine dedicated to PHP programmers

Come visit us at http://www.phparch.com!

--- Begin Message ---

   I have the following bit of information coming in that I need to 
generate key pairs of so I can drop it all into a database.  I'm 
creating tables for each section (SHIP_TO and BILL_TO) with matching 
Unique_IDs.  What's the best way to go about this (creating the pairs, 
stripping off excess spaces from some fields that have them after the 
last character, etc., etc.)

-- data --
 SHIP TO:
 Business Name:
 Contact Name: Ashley Kirchner
 Day Number:   303 442-6410
 Evening Number:
 Fax Number:
 Address:  3550 Arapahoe Ave., Ste. #6
 Address:
 Address:
 City: Boulder
 State/Province:   CO
 Zip/Postal Code:  80303
 Country:  USA

 BILL TO:
 Business Name:
 Contact Name: Ashley M. Kirchner
 Day Number:   303 4426410
 Evening Number:
 Fax Number:   303 442-9010
 Address:  3550 Arapahoe Avenue
 Address:  Suite #6
 Address:
 City: Boulder
 State/Province:   CO
 Zip/Postal Code:  80303
 Country:  USA
--


--
W | I haven't lost my mind; it's backed up on tape somewhere.
 +
 Ashley M. Kirchner    .   303.442.6410 x130
 IT Director / SysAdmin / WebSmith . 800.441.3873 x130
 Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] key pairs

2002-12-17 Thread Ashley M. Kirchner
Tim Ward wrote:


1. Have an order_id on the first table (or a separate 
ORDER table) that is INT and AUTO_INCREMENT.
2. Have an order_id on the other table(s) that is INT but 
not AUTO_INCREMENT.
3. Create the record in the first table just inserting the info 
you get in.
4. get the order_id just created using mysql_insert_id().
5. insert the data into the other table(s) with this order_id().
 

   Thanks, but that wasn't the question - I know this part. :)

   I need a routine to run through the data and generate the key pairs 
for insertion in the DB.

--
W | I haven't lost my mind; it's backed up on tape somewhere.
 +
 Ashley M. Kirchner    .   303.442.6410 x130
 IT Director / SysAdmin / WebSmith . 800.441.3873 x130
 Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] key pairs

2002-12-17 Thread Tim Ward
1. Have an order_id on the first table (or a separate 
ORDER table) that is INT and AUTO_INCREMENT.
2. Have an order_id on the other table(s) that is INT but 
not AUTO_INCREMENT.
3. Create the record in the first table just inserting the info 
you get in.
4. get the order_id just created using mysql_insert_id().
5. insert the data into the other table(s) with this order_id().

Tim Ward
http://www.chessish.com
mailto:[EMAIL PROTECTED]
- Original Message - 
From: Ashley M. Kirchner <[EMAIL PROTECTED]>
To: PHP-General List <[EMAIL PROTECTED]>
Sent: Tuesday, December 17, 2002 8:15 PM
Subject: [PHP] key pairs


> 
> I have the following bit of information coming in that I need to 
> generate key pairs of so I can drop it all into a database.  I'm 
> creating tables for each section (SHIP_TO and BILL_TO) with matching 
> Unique_IDs.  What's the best way to go about this (creating the pairs, 
> stripping off excess spaces from some fields that have them after the 
> last character, etc., etc.)
> 
> -- data --
>   SHIP TO:
>   Business Name:
>   Contact Name: Ashley Kirchner
>   Day Number:   303 442-6410
>   Evening Number:
>   Fax Number:
>   Address:  3550 Arapahoe Ave., Ste. #6
>   Address:
>   Address:
>   City: Boulder
>   State/Province:   CO
>   Zip/Postal Code:  80303
>   Country:  USA
>  
>   BILL TO:
>   Business Name:
>   Contact Name: Ashley M. Kirchner
>   Day Number:   303 4426410
>   Evening Number:
>   Fax Number:   303 442-9010
>   Address:  3550 Arapahoe Avenue
>   Address:  Suite #6
>   Address:
>   City: Boulder
>   State/Province:   CO
>   Zip/Postal Code:  80303
>   Country:  USA
> --
> 
> 
> -- 
> W | I haven't lost my mind; it's backed up on tape somewhere.
>   +
>   Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
>   IT Director / SysAdmin / WebSmith . 800.441.3873 x130
>   Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
>   http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] key pairs

2002-12-17 Thread Ashley M. Kirchner

   I have the following bit of information coming in that I need to 
generate key pairs of so I can drop it all into a database.  I'm 
creating tables for each section (SHIP_TO and BILL_TO) with matching 
Unique_IDs.  What's the best way to go about this (creating the pairs, 
stripping off excess spaces from some fields that have them after the 
last character, etc., etc.)

-- data --
 SHIP TO:
 Business Name:
 Contact Name: Ashley Kirchner
 Day Number:   303 442-6410
 Evening Number:
 Fax Number:
 Address:  3550 Arapahoe Ave., Ste. #6
 Address:
 Address:
 City: Boulder
 State/Province:   CO
 Zip/Postal Code:  80303
 Country:  USA

 BILL TO:
 Business Name:
 Contact Name: Ashley M. Kirchner
 Day Number:   303 4426410
 Evening Number:
 Fax Number:   303 442-9010
 Address:  3550 Arapahoe Avenue
 Address:  Suite #6
 Address:
 City: Boulder
 State/Province:   CO
 Zip/Postal Code:  80303
 Country:  USA
--


--
W | I haven't lost my mind; it's backed up on tape somewhere.
 +
 Ashley M. Kirchner    .   303.442.6410 x130
 IT Director / SysAdmin / WebSmith . 800.441.3873 x130
 Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php