I have a table called tbl_AllowedIpRange with the columns:
ipFrom | ipTo
I have two tables that represent entities that can have allowed IP’s assigned to them. tbl_Category and tbl_MediaItem.
What im wondering is how I link the two tables to reuse the tbl_AllowedIpRange table and keep things in the 3nf?
I was thinking that I could put two columns in the tbl_AllowedIpRange table?
CategoryId | MediaItemId | ipFrom | ipTo
Then write a two methods to get the alloed ip for each table trying to get access to it.
NOTE: I cant use one single column for the foreign key in the
tbl_AllowedIpRange because it will contain conflicting keys from the
other tables as it will point to their primary keys….
Is there an easier way using a link table?
Your table
tbl_AllowedIpRangeshould have an autoincrementPRIMARY KEY, which you can use to reference in other tables. So…1. Add a referenceable primary key to the table
tbl_AllowedIpRange2. Create a table to hold the relationship between
tbl_Categoryandtbl_AllowedIpRangeSuggested table name:
Category_AllowedIpRanges3. Create a table to hold the relationship between
tbl_MediaItemandtbl_AllowedIpRangeSuggested table name:
MediaItem_AllowedIpRanges