Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Should -Can- a parent be it's own child?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Should -Can- a parent be it's own child?

    Hi every one! I'm back to the well of wisdom with another question. I hope someone can shed a little light for me.

    It is my understanding, in a relational DB, that one of the main rules for normalization is to eliminate repetitive information. Another advantage of a relational DB is to avoid maintaining multiple tables with the same data through the use of child tables and relationships.

    Here is my problem and question:

    I am creating an order / billing application for a small manufacturing business.

    I need to have the ability for some of my customers to
    have the possibility of multiple ship to addresses.

    I first set my customer table up with this idea
    Cust1 ABC Corp Bill_to: Same
    Cust2 XYZ Corp store #1 Bill_to: XYZ Corp
    Cust3 XYZ Corp store #2 Bill_to: XYZ Corp
    Cust4 XYZ Corp store #3 Bill_to: XYZ Corp
    and so on.


    Then I spotted the repeating info an thought of a one-to-many table.
    For instance XYZ is the main customer and the billing would all go to:
    XYZ Corp
    123 Main
    This City USA

    But I can ship to:
    XYZ Corp Store in Main
    XYZ Corp Store in California,
    XYZ Corp Store in Colorado........... and so on.

    This eliminates the problem of repeating BUT doesn't this also introduce the need to maintain to sets of data when I have customers that the ship_to and bill_to are the same?

    So now my question: Can I (Would I want to?)link a partent table back on itself as a child?

    Thoughts on how I can handle this would be GREATLY appreciated.

    Scott



    #2
    RE: Should -Can- a parent be it's own child?

    FWIW

    I'd put all the addresses in the same table with the same company name (repeated each time) and all the addresses. In the invoice header I'd lookup the billing address and then lookup the shipping address.

    Another approach would be to put the company name in one table and link one to many to all the addresses. Lookup hte company name in the first table and lookup the billing and shipping addresses in the second table using a filtered lookup.

    Others probably have more and better ideas.

    Comment


      #3
      RE: Should -Can- a parent be it's own child?

      Scott
      I have the same issue where I have a customer linked to many shipping address by a one to many set.
      Keep in mind in your invoice header table you don�t need to have the Bill To address fields because you probably have a set for your order entry which includes the customer table as a 1 to 1 and is linked by the customer id field, but you do need to have fields to enter the shipping address so it can be changed for each address, now you could one field the �Ship To Name� which you can create in fields rules as a lookup to the shipping address table you need to add a filter something like �invoice_header->customer_id = customer_id� so only the address belonging to that customer will show up in the lookup.
      If you want a neater look put the shipping fields on the form and hide them and put an RTF field with the full shipping address now create button on the form to call an Xdialog box to enter the address
      See attached picture
      Here is an example which you will need to modify with field names

      CHANGE_SHIP_ADDRESS
      DIM v_sphone AS c
      v_sphone = topparent:Sphone.value
      DIM v_scontact AS c
      v_scontact = topparent:Scontact.value
      DIM v_scountry AS c
      v_scountry = topparent:Scountry.value
      DIM v_szip AS c
      v_szip = topparent:Szip.value
      DIM v_sstate AS c
      v_sstate = topparent:Sstate.value
      DIM v_scity AS c
      v_scity = topparent:Scity.value
      DIM v_sadd3 AS c
      v_sadd3 = topparent:Sadd3.value
      DIM v_sadd2 AS c
      v_sadd2 = topparent:Sadd2.value
      DIM v_sadd1 AS c
      v_sadd1 = topparent:Sadd1.value
      DIM v_stoname AS c
      v_stoname = topparent:Stoname.value

      DIM get_address as C
      DIM get_address_rl_def as C
      get_address_rl_def = "k=ship_add,{keylist_build(\"H=.025,1:60[Name],2:60[Address]\",''+recno(),left(''+Stoname,60),left(''+alltrim(Sadd1)+\" \"+alltrim(Sadd2)+\" \"+alltrim(Sadd3)+\" \"+alltrim(Scity),60))}{Cust_id = "+quote(cusid)+"}"
      dim rec[1] as p
      dim addr_get as L
      addr_get = .t.
      table_name = a5.Get_Path()+chr(92)+"ship_add.dbf"
      rec.initialize_from_table(table_name,"recno()=1")
      if eval_valid("rec[1].stoname") =.f.
      addr_get = .f.
      end if

      DIM new_ship_addr as C
      new_ship_addr = ui_dlg_box("Shipping Address",
      ;
      {endregion};
      %dlg%,1
      Rec.clear()
      rec.initialize_from_table(table_name,"recno()="+get_address)
      if eval_valid("rec[1].stoname") = .t.
      v_sphone = rec[1].Sphone
      v_scontact = rec[1].contact
      v_scountry = rec[1].Scountry
      v_szip = rec[1].Szip
      v_sstate = rec[1].Sstate
      v_scity = rec[1].Scity
      v_sadd3 = rec[1].Sadd3
      v_sadd2 = rec[1].Sadd2
      v_sadd1 = rec[1].Sadd1
      v_stoname = rec[1].Stoname
      end if
      end if
      a_dlg_button = ""
      else if a_dlg_button = "Cancel_button_click" .or. a_dlg_button = "save_button_click" then
      ' close
      else
      a_dlg_button = ""
      end if


      %code%)

      if new_ship_addr = "save_button_click"
      topparent.restrict_change = .f.
      topparent:Sphone.value = v_sphone
      topparent:scontact.value = v_scontact
      topparent:Scountry.value = v_scountry
      topparent:Szip.value = v_szip
      topparent:Sstate.value = v_sstate
      topparent:Scity.value = v_scity
      topparent:Sadd3.value = v_sadd3
      topparent:Sadd2.value = v_sadd2
      topparent:Sadd1.value = v_sadd1
      topparent:Stoname.value = v_stoname
      end if

      Daniel Weiss
      Daniel Weiss
      EZ Link Software

      Comment


        #4
        RE: Should -Can- a parent be it's own child?

        First off, yes, there are many situation where a parent can and should link to itself. In a contact database, for example, you might want to store relationships between people. Spouse, for example.

        You wouldn't have one table for husbands and one for wives. (And even if you did, mightn't THAT become an issue in this day of domestic partnership.) No, the sensible, flexible thing to do is to a table back to itself. Often this is done indirectly through intermediate tables. So, a contact record might link to an intermediate table that contains not just a link to other contact records, but also a description of the relationship, like spouse, parent, child, doctor, whatever.

        However, you don't really have a situation like that. :-) You want to store addresses, and a person might have more than one. One-to-many, straight up. The reason it seems complicated, perhaps, is that you're still keeping some address info in your base table. Don't. Put all addresses into a separate table. Right now you just have "ship to" and "bill to", but who knows? You might want to expand to using multiple ship to addresses (like with gift sending).

        ===Blake===

        Comment


          #5
          RE: Should -Can- a parent be it's own child?

          Hey guys -

          Thanks for the responses. Sorry I can't reply properly right now. I came in to a crashed network this AM. Looks like lightning... GRRRR! Tuesdays after a Monday holiday - Don't you love them??

          Will be back soon.

          Scott

          Comment

          Working...
          X