wintermutecz1
IS-IT--Management
I am having issues trying to find a way to enforce a constraint for a column that can store multiple values.
What I want to do is create a table that stores Sales. For each record in Sales, the broker(s) would be stored that were involved in the sale. The number of brokers involved could vary between 1 and X, so it would not be wise to create separate columns for Broker_1, Broker_2, Broker_3, etc. since there is no way to know before-hand exactly the number of brokers. Rather than creating dozens of Broker_# columns, I want to store all associated brokers in a single column either with a list or an array. The problem is that I don't want to allow a Broker_ID to be entered in this list (or array) if that Broker doesn't already exist in the table I use to store brokers.
Is there a way to get PostgreSQL to enforce a constraint (referential integrity) when the column could contain a list or array of Broker_IDs?
What I want to do is create a table that stores Sales. For each record in Sales, the broker(s) would be stored that were involved in the sale. The number of brokers involved could vary between 1 and X, so it would not be wise to create separate columns for Broker_1, Broker_2, Broker_3, etc. since there is no way to know before-hand exactly the number of brokers. Rather than creating dozens of Broker_# columns, I want to store all associated brokers in a single column either with a list or an array. The problem is that I don't want to allow a Broker_ID to be entered in this list (or array) if that Broker doesn't already exist in the table I use to store brokers.
Is there a way to get PostgreSQL to enforce a constraint (referential integrity) when the column could contain a list or array of Broker_IDs?