有没有办法在vb 2010上制作二维数据库?
我正在使用 VB 2010 Express 为我的老师朋友准备一个程序。他们保存有关学生的记录。我准备了一个数据库,其中包含一个名为“Mystudents”的表。它有“studentId、Name、Surname 等”等列。我的问题从这里开始。每个学生在一年内都要参加很多课程。我必须为每个学生保留“他们参加了哪些课程”,“他们何时参加”,“课程中完成了哪个主题”。例如
ID:104 姓名:杰森 姓氏:黑 等级:10A 2011年4月12日,他参加了数学课,他们做三角函数 2011年4月14日,他参加了物理课,他们做重力课 ………… ……
编号:105 姓名: 结婚 姓氏:管家 等级:11B 2011 年 4 月 2 日,她参加了数学课,他们做三角函数 2011年4月14日,他参加了物理课,他们做重力课 ………… ........
我的意思是我有一个数据库的每条记录的数据列表。请拦住我..?
Im preparing a program for my teacher friends using vb 2010 express. They keep records about their students. I prepared a database that contains a table named "Mystudents". It has columns like "studentId , Name, Surname, etc.." . My problem starts here. Each student attends lots of lessons during a year. I must keep "which lessons they attended", "when they attended", "which topic done in the lessons" for each students. for example
Id: 104
Name : Jason
Surname : Black
Class : 10A
on 12.04.2011 he attended math lesson and they do trigonomtry
on 14.04.2011 he attended physics lesson and they do gravity
.......
.......
Id: 105
Name : Marry
Surname : Steward
Class : 11B
on 02.04.2011 she attended math lesson and they do trigonomtry
on 14.04.2011 he attended physics lesson and they do gravity
.......
........
i mean i have a list of data for each record of databese. Please halp me..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在关系数据库设计中,您通常会包含一个“关系表”来跟踪这一点:
Student
表将StudentID
作为主键,Lesson< /code> 表将
LessonID
作为主键,Students_Lessons
表包含StudentID
和LessonID
两列这将把学生与课程联系起来。正如您在上面的数据库设计中看到的,
Student
表中的每条记录都可以链接到Students_Lessons
表中的零个或多个记录。Lesson
表也是如此;每条记录都可以链接到Students_Lessons
表中的零个或多个记录。但是,Students_Lessons
表中的每条记录必须恰好链接到Student
中的一条记录和Lesson
中的一条记录。如果每个学生只能参加每节课一次,您可以使用额外的列来扩展
Students_Lessons
表,以存储您需要的任何其他信息,否则最好使用额外的表来扩展数据模型来存储更多信息。In a relational database design, you would typically include a "relation table" to keep track of this:
The
Student
table haveStudentID
as primary key, theLesson
table hasLessonID
as primary key, and theStudents_Lessons
table contains the two columnsStudentID
andLessonID
which will link students to lessons.As you see in the database design above, each record in the
Student
table can be linked to zero or more records in theStudents_Lessons
table. The same goes for theLesson
table; each record can be linked to zero or more records in theStudents_Lessons
table. However, each record in theStudents_Lessons
table must be linked to exactly one record inStudent
, and one record inLesson
.If each student may attend each lesson once only, you can extend the
Students_Lessons
table with additional columns for any other information that you require, otherwise it's probably better to extend the data model with additional tables for storing more information.如果我没记错的话,您正在寻找 1-N 和 MN 关系。
最好的建议是您应该了解更多有关数据库设计的知识。您可以开始搜索关系数据库中的 1-N 和 MN 关系。
您希望在 VB 中支持这一点,但这超出了 .NET 范围,但它是数据库设计的事情:)
If I'm not wrong, you're looking for a 1-N and M-N relationship.
Best suggestion would be you should learn more about database design. You can start googing what's a 1-N and M-N relationship in relational databases.
You're looking to support that in VB, but this is out of .NET scope but it's a database design thing :)
问题是什么?
尝试写下您想要存储在数据库中的所有属性/实体。在此基础上,您可以执行一些规范化以实现最佳的数据库结构。
例如:一个学生有一个 ID、名字和姓氏。这些属性一起属于学生表。
更远;学生将遵循课程。但这不是1:1的关系。因此,首先您将获得一个“课程”表,其中定义了所有课程,之后您将获得一个 StudentsLessons 表,其中创建了课程与参加的学生之间的链接。
What is the question?
Try to write down all the properties/entities you'd like to store in your database. Based on that, you can perform some normalization to achieve the optimal database structure.
For example: a student's got an id, name and surname. Those properties belong together in a students table.
Further; a student will follow lessons. But this is not a 1:1 relationship. So in the first place you'll get a table 'lessons' where all lessons are defined, after that you'll get a StudentsLessons table where the link between lessons and the students attended is created.
我会用3张桌子。
谷歌搜索诸如“正常形式”、“一对多”、“多对多”和“多对一”关系之类的数据库设计内容会对您有所帮助。
I would use 3 tables.
Google-ing database design stuff like "normal form", "1 to many", "many to many" and "many to 1" relationships would help you here.