locked
Can you store multiple contacts in a record of a table? RRS feed

  • Question

  • Hello,

    I am helping friend by developing a database for him. Currently the database contains two tables: - the Company's details are found in one table while the Company Contacts' details are contained in another table:

    
    Company
    CompanyID
    Address1
    Address2
    Address3
    
    CompanyContacts
    ContactID
    CompanyID
    Title
    FirstName
    LastName
    Phone
    AlternatePhone
    MobilePhone
    Email
    AlternateEmail
    
     

    So my friend wants to mimic the structure of the data in a spreadsheet where both the Company data and the Contacts are stored on one table. Note a Company may contain two or three contact persons and each contact may have more than phone number and email address. I tried to explain to him that it is bad database design but he wants to see all of the Company and Contact details in one record, like this format: -

    Company
    CompanyID
    Address1
    Address2
    Address3
    Contact1
    Title1
    FirstName1
    LastName1
    Phone1
    AlternatePhone1
    MobilePhone1
    Email1
    AlternateEmail1
    Contact2
    Title2
    FirstName2
    LastName2
    Phone2
    AlternatePhone2
    MobilePhone2
    Email2
    AlternateEmail2
    Contact3
    Title3
    FirstName3
    LastName3
    Phone3
    AlternatePhone3
    MobilePhone3
    Email3
    AlternateEmail3
    
    Is this second approach - combined Company's details and Contact's details - in a table possible?

    N.B. if I used the first approach with the two separates: Company table and Contacts table and I create a report containing the Company data and the Contacts data, the Contact information will appear in multiple rows. Is this possible to have Contact details appear in one row if there are multiple Contacts?

    Thanks


    

    Friday, June 12, 2020 12:24 PM

Answers

  • The contacts must be stored in a separate related table.  In a report you can easily return the contacts horizontally across the page by embedding a subreport, linked on CompanyID, in the companies report, basing the subreport on the contacts table, and set its column layout to 'across then down' like this:

     

    Ken Sheridan, Stafford, England

    • Marked as answer by wirejp Friday, June 12, 2020 2:38 PM
    Friday, June 12, 2020 1:01 PM