Skip to main content

Relationship cardinality

Can be of three types: one-to-many, one- to-one, or many-to-many.

One-to-many (1:M). The most common type of relationship cardinality is a 1:M relationship. Consider the relationship between the EMPLOYEE and DEPARTMENT tables shown in Figure 1. The common column is DEPARTMENT_ID (which is the primary key in the DEPARTMENT table and the foreign key in the EMPLOYEE table). One individual DEPARTMENT_ID can relate to many rows in the EMPLOYEE table. This represents the business rule that one department can relate to one or many employees (or even no employees) and that an employee is associated with only one department (or, in some cases, no department). This business rule can be restated as follows: Each employee in a department may be in one and only one department, and that department must exist in the department table.



One-to-one (1:1). A 1:1 relationship between the DEPARTMENT table and the MANAGER table is depicted in Figure 2. For every row in the DEPARTMENT table, only one matching row exists in the MANAGER table. Expressing this as a business rule: Every department has at least one and at most one manager, and, conversely, each manager is assigned to at least one and at most one department.



One-to-one data relationships can exist, but they are not typically implemented as two tables (though they may be modeled that way). Instead, the data is combined into one table for the sake of simplicity.

Many-to-many (M:M). Consider the EMPLOYEE and PROJECT tables in Figure 3. The business rule is as follows: One employee can be assigned to multiple projects, and one project can be supported by multiple employees. Therefore, it is necessary to create an M:M relationship to link these two tables.



To support the relational database model, an M:M relationship must be resolved into 1:M relationships. Figure 4 illustrates this resolution with the creation of an associative table (also sometimes called an intermediate or intersection table) named EMPLOYEE_PROJECT.



In this example, the associative table’s primary key—a composite of its Employee_ID and Project_ID columns—is foreign-key-linked to the tables for which it is resolving an M:M relationship. It reflects that one employee can be assigned to multiple projects—and, in this example, that one employee can be assigned multiple and different responsibilities for each project to which that person is assigned. Note that the employee with an EMPLOYEE_ID value of 1234 is assigned to two projects but that his responsibilities are different for each project.

Comments

Popular posts from this blog

Oracle Developer Technical Interview Questions

Here i am putting all the questions i had faced during my interviews ... Interview at “3i InfoTech”, Chennai:  1) What is flow of execution of WHEN-NEW-FORM-INSTANCE, WHEN-NEW-BLOCK-INSTANCE, and WHEN-NEW-ITEM-INSTANCE? 2) What is PRE-QUERY and POST-QUERY? When these triggers will fire? 3) If the object library with some blocks and triggers if a form inherited that object library if u doesn’t need some trigger to be inherited the can u delete that trigger from that form? 4) How u can call a report from a form? Which property u has set in runtime? 5) If u create a relation between two blocks in the form what are all triggers it will create? 6) What is a ref cursor? 7) To call a form which type of built-ins u has to use? 8) What is the main difference between expand and variable property for a text item in reports. 9) In a report layout there is accepted and rejected fields and it has a parameter when u run the report based on the parameter the output should sh...

Communicating with a RDBMS Using SQL

What is SQL? SQL Stands for Structured Query Language. I t is the  international  standard language for relational database management systems. It is useful for  accessing and manipulating data in a databases.  To access the database, you execute a structured query language (SQL) statement, which is the American National Standards Institute (ANSI) standard language for operating relational databases.

INDEX Definition

In Oracle, an  INDEX  is a database object intended to improve the performance of  SELECT  queries. Indexes are created on table columns, and the index stores all the values of the column under index segments. If the  SELECT  query uses an indexed column in any of the  WHERE  conditions, the query uses the index segment instead of performing a full table scan. This results in enhanced query performance.