Re: The correct way to deal with name_1, name_2, name_3
- Original Message - From: Paul Fine [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 17, 2003 10:37 AM Subject: The correct way to deal with name_1, name_2, name_3 Greetings, I would be greatful for any advice on the correct way to do this. If I have something dynamic, for example customer names where usually there are 1 or 2 unique customer names but possibly say up to 10, what is the correct design? For example I could simply create a table with name_1, name_2, name_3 10. I am sure there is a more efficient way to do this. Could you be more specific? Do you mean one column for each name, in which case these would comprise 10 columns, most of which would have NULL most of the time? Or do you mean a separate row, one of whose columns is customer_name, with one of 10 values? I can't say much because of lack of detail (i.e., what's in the rest of the table), but I'd have TWO tables. In the table you're discussing, I'd have a column called cust_id. In another table, the customer table, I'd have two entries, cust_id and cust_name. cust_id in the original table would be a foreign key pointing at the customer table... Thanks! -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: The correct way to deal with name_1, name_2, name_3
Thanks. I do mean Do you mean one column for each name, in which case these would comprise 10 columns, most of which would have NULL most of the time? Is this your suggestion in this case: Table 1 | blahblah | blah | blah | CustID (PK) | Table 2 | CustID (FK) | Name | Table 2 Sample Data | 11 | Bart | | 11 | Jamie| | 11 | Bob | Therefore I can select NAME from Table 2 where CustID matches Table 1 and thus have all the names required? Thanks! -Original Message- From: Stephen Fromm [mailto:[EMAIL PROTECTED] Sent: Monday, November 17, 2003 10:01 AM To: Paul Fine; [EMAIL PROTECTED] Subject: Re: The correct way to deal with name_1, name_2, name_3 - Original Message - From: Paul Fine [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 17, 2003 10:37 AM Subject: The correct way to deal with name_1, name_2, name_3 Greetings, I would be greatful for any advice on the correct way to do this. If I have something dynamic, for example customer names where usually there are 1 or 2 unique customer names but possibly say up to 10, what is the correct design? For example I could simply create a table with name_1, name_2, name_3 10. I am sure there is a more efficient way to do this. Could you be more specific? Do you mean one column for each name, in which case these would comprise 10 columns, most of which would have NULL most of the time? Or do you mean a separate row, one of whose columns is customer_name, with one of 10 values? I can't say much because of lack of detail (i.e., what's in the rest of the table), but I'd have TWO tables. In the table you're discussing, I'd have a column called cust_id. In another table, the customer table, I'd have two entries, cust_id and cust_name. cust_id in the original table would be a foreign key pointing at the customer table... Thanks! -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: The correct way to deal with name_1, name_2, name_3
- Original Message - From: Paul Fine [EMAIL PROTECTED] To: 'Stephen Fromm' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, November 17, 2003 11:49 AM Subject: RE: The correct way to deal with name_1, name_2, name_3 Thanks. I do mean Do you mean one column for each name, in which case these would comprise 10 columns, most of which would have NULL most of the time? SF: OK Is this your suggestion in this case: Table 1 | blahblah | blah | blah | CustID (PK) | Table 2 | CustID (FK) | Name | Table 2 Sample Data | 11 | Bart | | 11 | Jamie| | 11 | Bob | SF: Mostly. Perhaps I'm not getting your design right, but to me CustID should be a PK in Table 2 and an FK in Table 1. It might also be a PK in Table 1, but that depends on the semantics of the table. But maybe that's not what you want because the CustID in the example you gave (in Table 2) is not unique for 3 different rows. Therefore I can select NAME from Table 2 where CustID matches Table 1 and thus have all the names required? SF: That's the basic idea. But given my confusion above, you should provide more details on the meaning of the tables. Thanks! -Original Message- From: Stephen Fromm [mailto:[EMAIL PROTECTED] Sent: Monday, November 17, 2003 10:01 AM To: Paul Fine; [EMAIL PROTECTED] Subject: Re: The correct way to deal with name_1, name_2, name_3 - Original Message - From: Paul Fine [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 17, 2003 10:37 AM Subject: The correct way to deal with name_1, name_2, name_3 Greetings, I would be greatful for any advice on the correct way to do this. If I have something dynamic, for example customer names where usually there are 1 or 2 unique customer names but possibly say up to 10, what is the correct design? For example I could simply create a table with name_1, name_2, name_3 10. I am sure there is a more efficient way to do this. Could you be more specific? Do you mean one column for each name, in which case these would comprise 10 columns, most of which would have NULL most of the time? Or do you mean a separate row, one of whose columns is customer_name, with one of 10 values? I can't say much because of lack of detail (i.e., what's in the rest of the table), but I'd have TWO tables. In the table you're discussing, I'd have a column called cust_id. In another table, the customer table, I'd have two entries, cust_id and cust_name. cust_id in the original table would be a foreign key pointing at the customer table... Thanks! -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]