一对多关系的新记录 [英] New record in a one-to-many relationship

查看:96
本文介绍了一对多关系的新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vb2005

我有一个具有一对多关系的表格. ``许多''表显示在一个数据网格中.

当我单击绑定导航器上的添加新按钮时.创建一个新的空白记录.填写一个"表中的字段后,我转到许多"表,这是一个用于填充字段的数据网格.填充数据网格中的第一行之后,我继续移至网格中的第二行,但数据网格中的第一行消失了.但是,单击保存"按钮时,将重新出现数据网格中的记录.


假设我有一个部门表,其中(部门ID,说明)与部门表(部门ID,部门ID,部门说明)相关.一个部门可以有很多部门.
我已经在数据网格中绘制了Department字段和Section字段.
创建部门后,我进入部分网格以输入部分(无需单击存储按钮).输入第一部分ID后,我尝试输入第二部分ID.但是,当我单击数据网格中的第二行时,先前输入的行消失了.但是,当我单击存储按钮时,先前输入的部分会重新出现.
知道为什么吗?


有人可以告诉我设计一对多关系时缺少什么吗?

谢谢

I''m using vb2005

I''ve a form with a one to many relationship. The ''many'' table is displayed in a datagrid.

When I click the add new button on the binding navigator. A new blank record is created. After filling the fields on the ''one'' table, I move on to the ''many'' table which is a datagrid to fill in the fields. After filling the first line in the datagrid, I move on to the second line in the grid but the first line in the datagrid disappears. However, when click on the save button , the record in the datagrid reappears.


Let''s say I''ve Department table with (Dept Id, Description) related to Section Table (Dept Id, Sect Id, Section description). One department can have many section.
I''ve painted the Department fields and the Section fields in a datagrid.
After creating a Department, I move on to the section grid to enter the sections (without clicking the store button). After entering the first section ID , I try to enter the second section Id. But when I click on the second row in the datagrid, the previously entered row disappeared. However when I click the store button, the previously entered section re-appears.
Any idea why?


Can you anyone tell me what is missing when designing one-to-many relationship?

Thanks

推荐答案

在关系数据库(一对多关系)中,您需要逐步添加记录.例如,如果您想收集有关汽车的信息,则需要建立这样的数据库:
TABLE TypesOfCars (TypeID, Note)-关系:一个
TABLE CarProducers (ProducerID, Name)-关系:一个
TABLE Cars (Name, TypeID, ProducerID)-关系:许多(具有TypeID和许多od ProducerID;外键)
在表格汽车中,您有2个字段,其来源来自其他表格.
要将记录添加到表Cars中,您需要知道TypeID和ProducerID.在TypeID和ProducerID不存在之前,您无法将新车添加到数据库中.您需要先添加Type和Producer(在添加新车之前)!
In the relational database (one to many relationship) you need to add records step by step. For example, if you want to collect information about cars, you need to build database like this:
TABLE TypesOfCars (TypeID, Note) - relation: one
TABLE CarProducers (ProducerID, Name) - relation: one
TABLE Cars (Name, TypeID, ProducerID) - relation: many (of TypeID and many od ProducerID; foreign keys)
In the table Cars you have 2 fields which source is comming from other table.
To add record to table Cars you need to know TypeID and ProducerID. Until TypeID and ProducerID not exists, you can''t add new car into your database. You need to add Type and Producer first (before add new car)!


这篇关于一对多关系的新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆