有没有办法在vb 2010上制作二维数据库?

发布于 2024-11-03 02:56:26 字数 431 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

木森分化 2024-11-10 02:56:26

在关系数据库设计中,您通常会包含一个“关系表”来跟踪这一点:

   --------------
   |  Student   |
   --------------
         | 1
         |      
         | 0..*
--------------------
| Students_Lessons |
--------------------
         | 0..*
         |
         | 1
   --------------
   |   Lesson   |
   --------------

Student 表将 StudentID 作为主键,Lesson< /code> 表将 LessonID 作为主键,Students_Lessons 表包含 StudentIDLessonID 两列这将把学生与课程联系起来。

正如您在上面的数据库设计中看到的,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:

   --------------
   |  Student   |
   --------------
         | 1
         |      
         | 0..*
--------------------
| Students_Lessons |
--------------------
         | 0..*
         |
         | 1
   --------------
   |   Lesson   |
   --------------

The Student table have StudentID as primary key, the Lesson table has LessonID as primary key, and the Students_Lessons table contains the two columns StudentID and LessonID 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 the Students_Lessons table. The same goes for the Lesson table; each record can be linked to zero or more records in the Students_Lessons table. However, each record in the Students_Lessons table must be linked to exactly one record in Student, and one record in Lesson.

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.

猫卆 2024-11-10 02:56:26

如果我没记错的话,您正在寻找 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 :)

相守太难 2024-11-10 02:56:26

问题是什么?

尝试写下您想要存储在数据库中的所有属性/实体。在此基础上,您可以执行一些规范化以实现最佳的数据库结构。

例如:一个学生有一个 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.

紫轩蝶泪 2024-11-10 02:56:26

我会用3张桌子。

students

student_id    student name .. etc ..
1             jane doe
2             jack dee


lessons

lesson_id    lesson_name   .. etc..
1            gravity 101
2            hard maths
3            hampsters  

student_lessons

student_id    lesson_id
1             1
1             2
1             3

谷歌搜索诸如“正常形式”、“一对多”、“多对多”和“多对一”关系之类的数据库设计内容会对您有所帮助。

I would use 3 tables.

students

student_id    student name .. etc ..
1             jane doe
2             jack dee


lessons

lesson_id    lesson_name   .. etc..
1            gravity 101
2            hard maths
3            hampsters  

student_lessons

student_id    lesson_id
1             1
1             2
1             3

Google-ing database design stuff like "normal form", "1 to many", "many to many" and "many to 1" relationships would help you here.

一生独一 2024-11-10 02:56:26
CREATE TABLE student
        (
        id INT NOT NULL PRIMARY KEY,
        firstName NVARCHAR(200),
        lastName NVARCHAR(200),
        )

CREATE TABLE subject
        (
        id INT NOT NULL PRIMARY KEY,
        subjectName NVARCHAR(200)
        )

CREATE TABLE class
        (
        id INT NOT NULL PRIMARY KEY,
        subjectId INT NOT NULL
                FOREIGN KEY
                REFERENCES subject,
        classDate DATE,
        topic NVARCHAR(200)
        )

CREATE TABLE student_class
        (
        studentId INT NOT NULL
                FOREIGN KEY
                REFERENCES student,
        classId INT NOT NULL
                FOREIGN KEY
                REFERENCES class,
        PRIMARY KEY (studentId, classId)
        )
CREATE TABLE student
        (
        id INT NOT NULL PRIMARY KEY,
        firstName NVARCHAR(200),
        lastName NVARCHAR(200),
        )

CREATE TABLE subject
        (
        id INT NOT NULL PRIMARY KEY,
        subjectName NVARCHAR(200)
        )

CREATE TABLE class
        (
        id INT NOT NULL PRIMARY KEY,
        subjectId INT NOT NULL
                FOREIGN KEY
                REFERENCES subject,
        classDate DATE,
        topic NVARCHAR(200)
        )

CREATE TABLE student_class
        (
        studentId INT NOT NULL
                FOREIGN KEY
                REFERENCES student,
        classId INT NOT NULL
                FOREIGN KEY
                REFERENCES class,
        PRIMARY KEY (studentId, classId)
        )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文