比较两个数据库之间的记录 [英] Comparing records between two databases

查看:98
本文介绍了比较两个数据库之间的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个特别复杂的问题,我想在这里解决。我在Access上有两个表,一个是"classes",一个是"学生"。

I've got a particularly complex issue that I'm trying to solve here. I have two tables on Access, one being "classes", and one being "students".

"学生"表表格是在我的注册/出勤计划上注册的每个学生的名单,每个学生都有指定的注册类别(即1A),这意味着我的课程将选择并显示适当的学生,并附上
相应的注册信函。 "类" table有不同类别识别号码(即1A1)的记录,针对不同的科目,其中还包括该班级的学生,每个记录一个人。

The "students" table is a list of every student registered onto my registration/attendance program, each of which has a designated registration class (i.e. 1A), which means that my program will select and display the appropriate students with the appropriate registration letters. The "classes" table has a record of different class identification numbers (i.e. 1A1), for different subjects, which also contains the students who are in that class, one person per record.

我在尝试什么要做的是匹配"类"中的记录名称。名字在"学生"里面 - 并仅显示"学生"所要求的姓名。那个"类"已将它们放入
我的软件的datagridview中。基本上,我需要我的程序来搜索"类"。数据库中有"学生"给出的名字列表。我尝试了很多解决方案,但无济于事。

What I'm trying to do is match the names of the records inside "classes" with the names inside "students" - and display only the names requested from "students" that "classes" has given them into a datagridview on my software. Essentially, I need my program to search through the "classes" database for a list of names given from "students". I've tried numerous solutions but to no avail.

对不起,如果我的问题很模糊,我对通过VB的SQL /数据库查询特别陌生 - 更不用说MSDN是在我的帐户经过验证之前不要让我发布截图 - 但是,非常感谢您的帮助。提前致谢!

Sorry if my question is quite vague, I'm particularly new to SQL/Database queries via VB - not to mention also that MSDN is not letting me post screenshots until my account is verified - however, your help is greatly appreciated. Thanks in advance!

推荐答案


大家好,

Hi all,

我有一个特别复杂的问题,我想在这里解决。我在Access上有两个表,一个是"classes",一个是"学生"。

I've got a particularly complex issue that I'm trying to solve here. I have two tables on Access, one being "classes", and one being "students".

"学生"表表格是在我的注册/出勤计划上注册的每个学生的名单,每个学生都有指定的注册类别(即1A),这意味着我的课程将选择并显示适当的学生,并附上
相应的注册信函。 "类" table有不同类别识别号码(即1A1)的记录,针对不同的科目,其中还包括该班级的学生,每个记录一个人。

The "students" table is a list of every student registered onto my registration/attendance program, each of which has a designated registration class (i.e. 1A), which means that my program will select and display the appropriate students with the appropriate registration letters. The "classes" table has a record of different class identification numbers (i.e. 1A1), for different subjects, which also contains the students who are in that class, one person per record.

我在尝试什么要做的是匹配"类"中的记录名称。名字在"学生"里面 - 并仅显示"学生"所要求的姓名。那个"类"已将它们放入
我的软件的datagridview中。基本上,我需要我的程序来搜索"类"。数据库中有"学生"给出的名字列表。我尝试了很多解决方案,但无济于事。

What I'm trying to do is match the names of the records inside "classes" with the names inside "students" - and display only the names requested from "students" that "classes" has given them into a datagridview on my software. Essentially, I need my program to search through the "classes" database for a list of names given from "students". I've tried numerous solutions but to no avail.

对不起,如果我的问题很模糊,我对通过VB的SQL /数据库查询特别陌生 - 更不用说MSDN是在我的帐户经过验证之前不要让我发布截图 - 但是,非常感谢您的帮助。提前致谢!

Sorry if my question is quite vague, I'm particularly new to SQL/Database queries via VB - not to mention also that MSDN is not letting me post screenshots until my account is verified - however, your help is greatly appreciated. Thanks in advance!

我正在尝试了解您的数据库布局。 这有点像你的东西吗?

I'm trying to understand your database layout.  Is this something like what you have?

学生:

姓名  ;             年龄          性别        等等

Fred                 42            男            无论是
Wilma              41             女性        无论是
Barney             38            男             无论

Students:
Name                Age            Gender          Etc
Fred                  42              Male              whatever
Wilma               41               Female          whatever
Barney              38              Male               whatever

Classes:

SubjectId        学生

1A1                弗雷德

1A1                 Barney

1B1                弗雷德

1B1               威尔玛

1B1                 Barney

Classes:
SubjectId          Student
1A1                  Fred
1A1                  Barney
1B1                  Fred
1B1                 Wilma
1B1                  Barney

这样的事情?

通常在多对多关系中(一个班有很多学生,一个学生可以有很多班)你需要三个表 - 一个用于定义所有学生,一个用于定义所有课程,第三个用于将学生与课程联系起来。 在上面的示例
中,没有定义类的表,因此没有什么可以限制SubjectId字段中的内容,也没有关于该类的其他信息。 这可能是不可取的。

Typically in a many-to-many relationship (one class has many students, one student can have many classes) you need three tables - one to define all the students, one to define all the classes, and a third to relate students to classes.  In the example above, there is no table defining a class so there's nothing to limit what goes in the SubjectId field and no other information about the class.  That probably isn't desirable.

这可能是通过定义关系然后在查询中使用连接或加载所有数据并在内存中导航关系来处理的。 但具体而言,这取决于数据库的设计和应用程序的预期
使用情况。

Chances are that this will be handled by defining relationships and then using a join in the query or loading all the data and navigating the relationships in memory.  But precisely how you do that will depend on the design of the database and the intended usage of the application.


这篇关于比较两个数据库之间的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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