麻烦决定表w / info [英] Trouble deciding tables w/ info

查看:63
本文介绍了麻烦决定表w / info的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。这是我自己制作的第一个数据库。我在2周前开始(使用2003年),打印了一个充满方向性,指导方针和操作方法的活页夹。来自多个地方。但是在两周之后,我对如何使用我的信息制作不同的内容一样无能为力!有人可以指导我吗???我知道主键说明,以及外键。我也知道你不应该重复用作主键的信息。然而,这就是我被难倒的地方。我在同一个表格中的字段的快速总结(我不会列出所有课程)如下:


自动编号 - (主键) -

SSN(文本数据类型)

姓氏(文字)

名字(文字)

中间名(文字)

Supv(文字)

课程1(日期/时间)

课程2,3,......(和等等)

已完成(这是一个复选框)

NS1(日期/时间)

NS2(日期/时间)


我实际上为这些课程制作了另一个表,其中包含以下字段:

TrainingType

CourseTitle

课程描述


除了员工桌子还有:

SSN

姓氏

名字

中间名


但我不知道如何与全部中的其他信息建立关系。 table(这是我最初输入所有信息的地方)。问题始于这些课程的日期设定,因为它们每月只提供一次。也许这很简单,我只是错过了它,并从一个小山丘中创造出一座山。我可以理解很多我读过的关于如何格式化你的表格的内容,但我不能得到表格而且我越来越沮丧!有人可以提供一些建议吗?非常感谢!我以为我至少理解Access,直到我仔细阅读这里的线程并意识到这里所说的语言显然比我能够理解的要高得多!

Hi. This is the first database I have produced myself. I began 2 wks ago (using 2003), have printed a binder-full of directions, guidelines, and "how-to''s" from multiple places. But after 2 weeks I am just as clueless on HOW to make different tbls with my information! Can someone please direct me??? I know about the primary key instructions, as well as foreign keys. I also know you''re not supposed to repeat information that is used as a primary key. However, that''s where I get stumped. A quick summation (I won''t list all the courses) of the fields I have within the same table currently are as follows:

AutoNumber--(primary key)--
SSN (text data type)
Last Name (text)
First Name (text)
Middle Name (text)
Supv (text)
Course 1 (date/time)
Course 2, 3.......(and on and on)
Completed (which is a checkbox)
NS1 (date/time)
NS2 (date/time)


I have actually produced another table for the courses which has the following fields:
TrainingType
CourseTitle
CourseDescription

As well as a table for employees which has:
SSN
Last name
First name
Middle name

But I have no idea how to make relationships from the rest of the information in the "all" table (which is where I initially input ALL of the info). The problem starts in that the dates for the courses are set because they''re only offered once a month. Perhaps this is so simple that I''m just missing it and making a mountain out of a molehill. I can understand alot of what I''ve read regarding how to later format your tables, but I just can''t get the tables and I am growing frustrated!!! Can someone offer some advice please? Thank you so much! I thought I was at least understanding Access until I perused through the threads on here and realized the language spoken here is clearly on a much-higher level than I can easily comprehend!

推荐答案

那里。


这样的东西。实现PK / FK关系的字段用粗体表示。


表:tblEmployees
Hi, there.

Something like this. Fields implementing PK/FK relationship are bolded.

Table: tblEmployees
< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号


Deanndra


在我看来,你问的是你如何设置这些数据,以便表格是关系的(并且有效?)。我不是专家,所以在得到专家回复之前可能值得坚持下去,但是对于这些是值得的,这些是我的观察结果;


看起来你好吗?从第3个表中复制数据,将其再次存储在第一个表中? SSN,姓名数据?但是你在正确的轨道上。


相反,试试这个:


1.填写tblEmployees表(和提示,使用从一开始就是这种命名协议,它会为你节省大量的麻烦和混乱。

2.如果SSN是一个没有重复的唯一字段,请将其作为主键。否则,添加一个名为eg的新字段。 EmployeeID,将其属性设置为自动编号,并将其设为主键。

3.对于其余字段,我只是建议丢失单词之间的间隙,即将姓氏更改为LastName等让以后的生活变得更轻松。

4.接下来,对于课程表(tblCourses)执行相同类型的操作,创建一个包含名为CourseID,property = autonumber的字段的唯一课程表,把它作为主键

5.您可以将课程日期字段添加到此表中,但我不会,因为您将最终存储课程名称等多次,而不是您需要

6.我创建了另一个名为eg的表tblCourseDates?这实际上是你提到的第一个表格

7.同时给这个表格一个自动编号,主键字段叫做例如CourseDateID

8.然后给它一个名为CourseID的字段(匹配tblCourses主键),将属性设置为number。在设计模式的这个领域,使用?查找?左侧的boot选项卡,将显示控件更改为组合。创建rowsourcetype表/查询。对于rowsource,使用右侧的构建按钮创建包含CourseID和CourseName字段的tblCourses查询。这使得在tblCourseDetails中更容易理解你的数据

9.还给它一个名为EmployeeID的字段,也作为一个数字并执行相同的查找。

10.添加在您的课程日期字段,主管领域等。如果您有不同的主管用于不同的课程,请考虑创建一个单独的tblSupervisors,将其连接到tblCourseDetails,如下所述。

11.现在,在关系窗口中,将tblEmployees中的EmployeeID字段连接到tblCourseDates中的相应字段;并且对tblCourses和tblCourseDates做同样的事情。

12.现在,用他们的生物细节填充tblEmployees

13.用不同的课程细节填充tblCourses

14.在tblCourseDetails(或表格)的编辑视图中,您现在可以选择课程名称,选择员工姓名,并添加日期和其他详细信息,即您避免复制基本课程详细信息和员工详细信息。

15.

16.这应该给你一个漂亮,健全,关系,标准化的基础,显然你可以根据这些原则定制。
Deanndra

It looks to me like what you?re asking is how do you set up this data so that the tables are relational (and efficient?). I?m not an expert so it might be worth hanging on until you get an experts reply, but for what it?s worth these are my observations;

It seems like you?re duplicating the data from the 3rd table mentioned, storing this again in the first table? SSN, Name data? But you?re on the right track.

Instead, try this:

1. Complete the tblEmployees table (and a tip, use this kind of naming protocol from the outset, it?ll save you loads of hassle and confusion later).
2. If SSN is a unique field with no duplicates, make this the primary key. Otherwise, add in a new field called e.g. EmployeeID, set it?s property to autonumber, and make this the primary key.
3. For the remainder of the fields, I?d just suggest losing the gaps between words, i.e. change Last name to LastName etc. makes life easier later.
4. next, do the same kind of this for the courses table (tblCourses), create a table of unique courses with a field called CourseID, property = autonumber, make this the primary key
5. You could add in the course date fields into this table, but I wouldn?t, as you?ll end up storing the course name etc more times than you need to
6. I?d create a further table called e.g. tblCourseDates ? this is effectively the first table you mention
7. Also give this one an autonumber, primary key field called e.g. CourseDateID
8. Then give it a field called CourseID (matching the tblCourses primary key), set the property to number. Whilst in this field in design mode, use the ?lookup? tab at the bootom left and change the display control to a combo. Make the rowsourcetype table/query. For the rowsource, use the build button just to the right to create a query of the tblCourses which includes the CourseID and CourseName fields. This makes it easier to understand your data in tblCourseDetails
9. Also give it a field called EmployeeID, also as a number and do the same lookup thing.
10. Add in your course date fields, supervisor field etc. NB. If you have lots of different supervisors for different courses, consider creating a separate tblSupervisors, joining this to tblCourseDetails along the same lines as described below.
11. Now, in the relationships window, connect the EmployeeID field from tblEmployees to the corresponding field in tblCourseDates; and do the same for tblCourses to tblCourseDates.
12. Now, populate the tblEmployees with just their bio-details
13. populate the tblCourses with the different course details
14. In edit view in tblCourseDetails (or in a form) you can now select the course name, select the employee name, and add in the dates and other details, i.e. you avoid replicating the basic course details and employee details.
15.
16. This should give you a nice, sound, relational, normalised base and obviously you can tailor these principles to suit.


您好,欢迎来到脚本! (特别是Access论坛:-)

关系数据库的关键是你应该只在一个地方存储一条信息。然后根据您在表格之间创建的关系来访问。


显然有时您必须在多个地方存储某些东西,但这些情况以最小化冗余数据的方式处理。


设计数据库的第一部分是决定它将用于什么。第二是收集所有将要存储的信息并检查它的目的和特征。


我们将以您的第一张表为例。您显然存储学生信息?假设是这样,我们已经确定了您的数据库的一个 主题 。属于这个主题的是几个特征:姓名(第一个,最后一个和中间),SSN,地址,电话号码等。在你的表中你添加了许多课程字段,但正如你将看到的,这些确实不属于''学生''科目!我看到你有一个课程表,这是非常好的。


现在,让我们分析学生和课程科目之间的关系。一名学生可以参加多个班级,这告诉我们学生和课程之间存在一对多的关系。现在,扭转局面,一个班级可以与多个学生联系吗?显然是的......这告诉我们课程和学生之间也存在一对多关系,这导致学生表和课程表之间的多对多关系。


使这种关系发挥作用的最好方法是创建第三个表,将多对多关系分解为两个一对多的关系。称之为tblStudentCourses,并给它三个字段:StudentCourseID,StudentID和CourseID。


现在当你在数据库窗口时,在工具栏上你会看到一个符号看起来像<标志。它象征着关系图。单击它,它将打开用于创建/定义数据库中关系的窗口。在空窗口中单击鼠标右键,然后选择显示所有表。通过单击并拖动来排列它们,然后您就可以开始创建关系了。首先找到Students表,然后单击并将StudentID(或SSN,如果您将其用作主键)从Students表拖动到StudentCourses表中的相应ID字段。这将打开对话框,只需单击确定,即可创建关系。重复课程表,你现在已经定义了学生和课程之间的关系。


有一本我推荐过很多次的书,我也会推荐给你! Mike Hernandez的第二版数据库设计。我在周围见过它
Hello and welcome to the Scripts! (especially the Access forum :-)

The essential thing about a Relational Database is that you should only store one piece of information in one place. It then is ''accessed'' according to the relationships that you create between your tables.

Obviously there are times when you have to store something in more than one place, but those situations are handled in such a way as to minimize the redundant data.

The first part of designing a database is deciding what it will be used for. Second is collecting all the information that will be stored and examining it for it''s purpose and characteristics.

We''ll look at your first table as an example. You are apparently storing student information? Assuming so, we have identified one subject of your database. Belonging to this subject are several characteristics: Name (first, last and middle), SSN, address, phone #, etc. In your table you have added a number of Course fields, but as you will see, these really are not part of the ''Student'' subject! I see you have a Course table, which is excellent.

Now, let''s analyze the relationship between the Student and Course subjects. One student can attend multiple classes, this tells us that a One to Many relationship exists between Students and Courses. Now, turning it around, can one class be associated with more than one student? Obviously yes... this tells us that a One to Many relationship also exists between Courses and Students, this results in what is called a Many to Many relationship between the Students table and the Courses table.

The best way to make this relationship work is by creating a third table that will break the many to many relationship down into two one to many relationships. Call it tblStudentCourses, and give it three fields: StudentCourseID, StudentID, and CourseID.

Now when you are in the database window, on the tool bar you will see a symbol looking something like the < sign. It symbolizes the relationship diagram. Click it, and it will bring up the window for creating/defining the relationships in your database. Right-click in the empty window and choose Show All tables. Arrange them by clicking and dragging as you wish, and then you can begin creating the relationships. First of all locate the Students table, then click and drag the StudentID (or SSN if you are using it as a primary key) from the Students table to the corresponding ID field in the StudentCourses table. This will bring up the dialog box, just click OK, and the relationship is created. Repeat with the Courses table, and you have now defined the relationship between Students and Courses.

There is a book that I have recommended many times and I will recommend it to you also! Database Design for Mere Mortals, Second Edition, by Mike Hernandez. I''ve seen it for around


这篇关于麻烦决定表w / info的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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