|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Junction tablesI have the following tables and I am unsure of the benefits of using a
junction table to join (for lack of a better word) the two tables. table 1 ClientID StateID table 2 StateID State I am in the development stages, so I can do it either way. I just want to understand why one way is recommended over the other. Based upon the limited information, it doesn't appear that you need a
'junction' table. Table1 is directly linked to Table2 by StateID. -- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "Curtis" <Cur***@discussions.microsoft.com> wrote in message news:40B90F66-F727-4278-AAE2-E931CD5ED173@microsoft.com... >I have the following tables and I am unsure of the benefits of using a > junction table to join (for lack of a better word) the two tables. > > table 1 > ClientID > StateID > > table 2 > StateID > State > > I am in the development stages, so I can do it either way. I just want to > understand why one way is recommended over the other. >> I am in the development stages, so I can do it either way. I just want to In a nutshell, a table should represent only one set of entities, or a >> understand why one way is recommended over the other. single entity type. The goal is that one would want to update/delete one set of entities without affecting the other. The general design rules of thumb are: --- When you have a 1-to-1 relationship between two entity types, unless there are any non-dependency preserving relationships, you may represent them in a single table. --- When you have a m-to-1 relationship between two entity types, you should use a referential integrity constraint ( FK ) between the tables representing each entity types. --- When you have an m-to-n relationship between two or more entity types, you should introduce an "association" table (or "junction" table as you put it ) that reduces the schema to two or more many-to-one relationships on each table representing individual entity types. -- Anith |
|||||||||||||||||||||||