I have a curly problem!
I have an Access database containing customer marketing information, which I've normalised and contains the following tables:
- CustDetail (customers name, email, address etc. PK=Autonumber)
- Industry (customer industries PK=Autonumber)
- CustIndustry (contains 2 foreign keys from Industry & CustDetail to link customers to multiple industries PK=CustID+IndustryID)
- Company (contains company names PK=Autonumber. CustDetail table has CompanyID foreign key to identify customers company)
This works fine and allows customers to be members of multiple industries as is usually the case in our experience. The database has been written for a web based front end for adding and modifying data.
The problem I have is that occasionally we have a need to perform a batch import of customers from an Excel spreadsheet. The spreadsheet contains all this customer data in one table.
I've fiddled with this most of the day but cant see how I can do it - the main problem being the link table "CustIndustry" which requires primary keys from the Industry table and the CustDetail table - both of which the spreadsheet doesnt contain. In the spreadsheet the industries are column headings with a 0 or 1 identifying if a customer is a member or not.
Also the company name - some companies in the spreadsheet already exist in the Access table "Companies" but then some dont. For the batch import to work, the query would have to check the company table for the company, if it doesnt exist - add it, then get the CompanyID and insert into the CustDetail record - for each customer in the spreadsheet?!
It all adds up to a nightmare SQL problem - well for me anyway! I'm thinking that if it is at all possible I may have to modify the spreadsheet layout to better accomodate an import - but to what?
If it looks to be too much trouble I will just insert the CustDetail table data, send the customers an email and get them to add their own company and industry details via the web front end.
Any help/hints much appreciated.
I have an Access database containing customer marketing information, which I've normalised and contains the following tables:
- CustDetail (customers name, email, address etc. PK=Autonumber)
- Industry (customer industries PK=Autonumber)
- CustIndustry (contains 2 foreign keys from Industry & CustDetail to link customers to multiple industries PK=CustID+IndustryID)
- Company (contains company names PK=Autonumber. CustDetail table has CompanyID foreign key to identify customers company)
This works fine and allows customers to be members of multiple industries as is usually the case in our experience. The database has been written for a web based front end for adding and modifying data.
The problem I have is that occasionally we have a need to perform a batch import of customers from an Excel spreadsheet. The spreadsheet contains all this customer data in one table.
I've fiddled with this most of the day but cant see how I can do it - the main problem being the link table "CustIndustry" which requires primary keys from the Industry table and the CustDetail table - both of which the spreadsheet doesnt contain. In the spreadsheet the industries are column headings with a 0 or 1 identifying if a customer is a member or not.
Also the company name - some companies in the spreadsheet already exist in the Access table "Companies" but then some dont. For the batch import to work, the query would have to check the company table for the company, if it doesnt exist - add it, then get the CompanyID and insert into the CustDetail record - for each customer in the spreadsheet?!
It all adds up to a nightmare SQL problem - well for me anyway! I'm thinking that if it is at all possible I may have to modify the spreadsheet layout to better accomodate an import - but to what?
If it looks to be too much trouble I will just insert the CustDetail table data, send the customers an email and get them to add their own company and industry details via the web front end.
Any help/hints much appreciated.