آموزش دات نت, بانک های اطلاعاتی

آموزش برنامه نویسی دات نت

آموزش دات نت, بانک های اطلاعاتی

آموزش برنامه نویسی دات نت

Relation Ships-One-to-Many

Relation ارتباط بین جداول می باشد مثلا در شکل بالا جدول Employees یا کارمندان  جدول Master

و جدول EmployeesWorkTimes جدول ورود و خروج کارمندان جدول Detail میباشد این دو جدول با یکدیگر رابطه One To Many دارند طوری که مقادیر PersonalID در جدول EmployeesWorkTimes از جدول Master آن یعنی Emplyees میآید و این به این معنی است که تنها کارمندانی که در جدول Employees ثبت شده اند میتوانند ساعت ورود و خروج داشته باشند.این ارتباط در جدول Master روی Primary Key , فیلد Uniqe برقرار میشود  یعنی ۱ سمت حتما باید Uniqe باشد. به فیلد PersonalID در جدول Childیا EmployeesWorkTimesکلید خارجی یا Forign Key میگویند و فیلد PersonalID در جدول Master که همان جدول کارمندان است کلید اصلی یا Primary Key گفته میشود.

 

One-to-Many Relationships

A one-to-many relationship is the most common type of relationship. In this type of relationship, a row in table A can have many matching rows in table B, but a row in table B can have only one matching row in table A. For example, the publishers and titles tables have a one-to-many relationship: each publisher produces many titles, but each title comes from only one publisher.

Make a one-to-many relationship if only one of the related columns is a primary key or has a unique constraint.

The primary key side of a one-to-many relationship is denoted by a key symbol. The foreign key side of a relationship is denoted by an infinity symbol.