Introduction
The most common relationship in any data model is the one-to-many non-identifying relationship. Non-identifying relationship implies weak dependency relationship between parent and child entities. There are two kinds of non-identifying relationships, including optional and mandatory. The necessity of the parent entity is "exactly one" and "zero or one" in the mandatory and optional non-identifying relationship respectively. One problem I've tackled in many of my enterprise application is the presentation of complex data relationship such as optional non-identifying relationship using data binding techniques in Windows Forms applications. In this article, I will illustrate how to face this problem.
Getting started with the solution
Let's supposed that we have the table schema for the dept and emp tables representing the department and employee business entities respectively (see Listing 1). This is an optional one-to-many non-identifying relationship where the dept table is the parent and the emp table is the child.
CREATE TABLE [dbo].[dept](
[deptno] [int] NOT NULL,
[dname] [varchar](60) NULL,
[loc] [varchar](60) NULL,
[rowversion] [timestamp] NOT NULL,
PRIMARY KEY CLUSTERED([deptno] ASC)
)
go
CREATE TABLE [dbo].[emp](
[empno] [int] NOT NULL,
[ename] [varchar](60) NULL,
[salary] [numeric](7, 2) NULL,
[deptno] [int] NULL,
[rowversion] [timestamp] NOT NULL,
PRIMARY KEY CLUSTERED( [empno] ASC )
) ON [PRIMARY]
go
ALTER TABLE [dbo].[emp] WITH CHECK ADD CONSTRAINT [FK_emp_dept] FOREIGN KEY([deptno])
REFERENCES [dbo].[dept] ([deptno])
ON UPDATE CASCADE
ON DELETE CASCADE
go
ALTER TABLE [dbo].[emp] CHECK CONSTRAINT [FK_emp_dept]








Join the conversation! Your thoughts help the community grow.