Expand all | Collapse all

1 to 1 Relationship

  • 1.  1 to 1 Relationship

    Posted 03-22-2017 16:51
    Can Quickbase support a 1 to 1 relationship?

    I have an application that consists of 2 tables, Orders and Equipment.  Orders are created by hand while Equipment is a predefined list of records i.e. Dell Computer Serial Number 1234, Dell Computer Serial Number 1235 etc.

    An Equipment record can only be associated with a single Order but an Order can have many Equipment.  (The current relationship is that an Order can have many Equipment.)  But.. the Equipment table should be static data, the user should not have to create an Equipment record each time they are creating an Order record. Rather than Add an Equipment record from the Order page i'd like to link or relate an Equipment record with an Order, is this possible?

  • 2.  RE: 1 to 1 Relationship

    Posted 03-22-2017 17:03
    What you would usually do here is have an orders table, and equipment table, and a line items table, where an order can have many line items, an equipment item can have many line items. 

    From there you can add a quantity field to the line item record, and a total field that takes the base equipment price multiplied by the quantity. 

    Delete your existing orders to equipment relationship and give the above a shot. it is the standard way of handling what you are describing. 

    good luck!

  • 3.  RE: 1 to 1 Relationship

    Posted 03-22-2017 20:09
    But each equipment only has a quantity of 1.  All equipment is unique, there's not a pool of a single "Equipment".

  • 4.  RE: 1 to 1 Relationship

    Posted 03-22-2017 20:34
    Ok - that being said, I think you would still have the same tables. I laid out above. However, once an equipment has a child 'line item' record, it would not show up in the list for the next time you add a line item to an order. You still need a place to store these unique equipment assets. And, in order to link many of these unique equipment assets to one order, you need a join table. 

    So to implement this, create a summary field on the equipment table that counts the number of line items related. Then, create a formula field (text or checkbox) that has a formula something like: if([# of Line Items]=0,"Available","Issued") where if there line items is equal to 0, it is available, if it is not equal to 0, it has been issued. 

    Then create a report labeled 'Available Equipment' I would recommend only putting 1 to 3 fields on that report. Add a filter to that report: where [# of Line Items]=0. This report will be your active equipment list for use on orders.

    Now go to your line item table form, and on the form element for the equipment reference field, have it display choices from your 'Available Equipment' report instead of the standard record picker fields. 

    That should do it.

  • 5.  RE: 1 to 1 Relationship

    Posted 03-22-2017 21:55
    That did it, you nailed it.  Thank you Eric!