Database ERD-Guiding Beacon
In case of a one-to-many relation, both the entities stand as separate tables, with the primary key of the first entity appearing in the second, too (as a foreign key, as explained elsewhere). Please note that many-to-one relationship would be just a replica of one-to-many relationship and hence is not discussed separately. Lastly, if it is many-to-many relationship, the relation itself gets resolved into yet another table with its primary key as composition of primary keys of both the tables. A few examples will make this point clear for you:
One-to-many relationship
Consider a political system where a state contains several districts. As one state contains multiple districts – and the number of districts varies from state to state – we cannot think of storing a district code in the state file. It may need multiple district fields within a single state file. (Remember, the repeating groups’ problem in normalization?) However, it is possible to relate the two entities by storing the state code in the district file, as there is just one state for each district.
Related links: Database Assignment Help
|