I have a design that I have set up and I could really use some help to see if I am on the right track. If this is not an appropriate question for *, I apologize and I will remove it. I'm a fairly new user and not 100% sure.
我有一个设计,我已经设置,我真的需要一些帮助,看看我是否在正确的轨道上。如果这对*来说不是一个合适的问题,我很抱歉,我将删除它。我是一个相当新的用户,不是百分之百的肯定。
I am building a content manager and everything is coming dynamically from the database. I have a page that has sections and these sections have fields and data is entered into these field. The fields could be textboxes, comboboxes or listboxes. The point here is to be able to create pages, these pages get the appropriate sections with fields based on the section type and I simply want to store the values so that the page can be read or edited later.
我正在构建一个内容管理器,一切都是从数据库中动态来的。我有一个有部分的页面,这些部分有字段,数据被输入到这些字段中。字段可以是文本框、组合框或列表框。这里的要点是能够创建页面,这些页面根据节类型获得适当的节,我只想存储值,以便以后可以读取或编辑页面。
Page1
所述
Section1
Section1
field1 [Texbox1]
field2 [Texbox2]
field3 [Combobox1]
field1 [Texbox1] field2 [Texbox2] field3 [Combobox1]
Section2
Section2
field1 [Texbox1]
field2 [Listbox1]
field3 [Combobox1]
field1 [Texbox1] field2 [Listbox1] field3 [Combobox1]
The sections can be reused on different pages and the fields are always the same on every section.
各个部分可以在不同的页面上重用,并且每个部分的字段都是相同的。
My database looks like this:
我的数据库是这样的:
Page
* PageId
* PageName
页面* PageId * PageName
Page_Section
* PageId
* SectionId
Page_Section * PageId * SectionId
Section
* SectionId
* SectionTypeId
* SectionName
Section * SectionId * SectionTypeId * SectionName
SectionType
* SectionTypeId
* SectionTypeName
SectionType * SectionTypeId * SectionTypeName
Field
* FieldId
* SectionId
* FieldName
字段* FieldId * SectionId * FieldName
FieldValue
* FieldValueId
* FieldId
* FieldValueValue
* Current Value (This is a bit because a combobox could have multiple values but I wanna show which one is selected. Similarly, a listbox could have multiple values selected)
* PageId
FieldValue * FieldValueId * FieldId * FieldValueValue * Current值(这有点因为combobox可以有多个值,但我想显示所选的是哪个值。类似地,列表框可以选择多个值)* PageId
So a page is created with the sections based on a section type. Each section has x number of fields and then obviously each page field can have a different value that's why FieldValue has pageId but it feels weird to put in that pageId in FieldValue but I see no other way. Am I on the right track?
因此,一个页面是基于部分类型创建的。每个部分都有x个字段,显然每个页面字段都有不同的值,这就是为什么FieldValue有pageId的原因但是在FieldValue中输入pageId会感觉很奇怪,但是我没有看到其他的方式。我走对方向了吗?
3 个解决方案
#1
2
I think you're on the right general track.
我认为你的思路是对的。
One area I'd worry about is the sequencing of sections on each page — I think your Page_Section table needs an extra column SeqNo SMALLINT NOT NULL
which takes values in increasing order (they don't have to be contiguous), so that when you order by SeqNo, your sections will be presented in the correct order on the page.
我担心的一个领域是部分在每个页面的排序——我认为你Page_Section表需要一个额外的列SeqNo SMALLINT NOT NULL将值增加订单(他们不必是连续的),所以当你SeqNo顺序,你的部分会呈现在页面上以正确的顺序。
You might need a similar sequencing column for fields within a section.
您可能需要一个类似的排序列用于一个区段中的字段。
Your Field table will probably need some field type information.
您的字段表可能需要一些字段类型信息。
Maybe your FieldValue table should be renamed to PageFieldValue; it is designed to associate a value with the field on a particular page. As long as a given field can't appear more than once on a page, the renamed table is accurately named; it contains the value of a field on the nominated page. It isn't clear whether there can be some sort of default system so that if a page doesn't specify a particular value for a field, then the default value kicks in. It might be worth thinking about.
也许您的FieldValue表应该重命名为PageFieldValue;它被设计成将一个值与特定页面上的字段相关联。只要给定字段在页面上出现不超过一次,重命名的表就会被正确命名;它包含指定页面上字段的值。目前还不清楚是否存在某种默认系统,因此,如果页面没有为字段指定特定的值,那么默认值就会出现。这可能值得考虑。
#2
1
My big question would be, What is it that you are trying to record? Is the point to record the aassignment of fields to sections and sections to pages? Or is the point to record business data that just happens to be split across multiple sections and pages because of limits of screen size, etc?
我最大的问题是,你想记录的是什么?是否要将字段分配到节,节分配到页?或者,记录业务数据的目的是由于屏幕大小等限制而在多个部分和页面上进行分割吗?
For example, suppose on page 1 we have, say, customer name and address, and on page 2 we have account number and phone number. If tomorrow someone were to redesign the screen to move the account number to page 1, then your present database would require major data updates to move all the field records for account numbers from page 2 to page 1. If this is important to whatever you want to do with the data, like if you want to query "get me a list of all the fields on page 3", then that's simply how it is, and your design here is a good one. But if the association of fields to pages is just a coincidental fact, and not something you would care about in queries, then you're heading in the wrong direction. If that's the case, I would leave out everything about pages and sections and instead think of the business objects about which you are collecting data, like customers and stores and products or whatever it is.
例如,假设在第1页,我们有客户名称和地址,在第2页我们有帐号和电话号码。如果明天有人要重新设计屏幕,将帐户号移动到第1页,那么您当前的数据库将需要重大数据更新,以便将帐户号的所有字段记录从第2页移动到第1页。如果这对你想要处理的数据很重要,比如你想要查询“给我一个第3页上所有字段的列表”,那么这就是你的设计。但是如果字段与页面的关联只是一个巧合的事实,而不是您在查询中关心的内容,那么您就会朝着错误的方向前进。如果是这样的话,我将省略有关页面和部分的所有内容,而是考虑您正在收集数据的业务对象,如客户、商店和产品或其他内容。
That is, is this a "screen layout database", or is it a "customer information database" or "product database" or some such? If it's a screen layout database, then you're on the right track. If it's a product database, then you're on the wrong track.
也就是说,这是一个“屏幕布局数据库”,还是一个“客户信息数据库”或“产品数据库”?如果它是一个屏幕布局数据库,那么您就走对了路。如果它是一个产品数据库,那么您就走错了路。
#3
0
Depending on the applications, if a section has fixed fields and is frequently accessed, you can perform denormalization for that section to improve the query performance. In a way, you can create a table section_x:
根据应用程序的不同,如果一个区段有固定的字段并且经常被访问,您可以为该区段执行非规范化,以改进查询性能。在某种程度上,您可以创建一个表section_x:
section_x
field_1
field_2
...
field_n
You can find more about denormalization on this wiki page: https://en.wikipedia.org/wiki/Denormalization
您可以在这个wiki页面上找到更多关于非规范化的信息:https://en.wikipedia.org/wiki/Denormalization
#1
2
I think you're on the right general track.
我认为你的思路是对的。
One area I'd worry about is the sequencing of sections on each page — I think your Page_Section table needs an extra column SeqNo SMALLINT NOT NULL
which takes values in increasing order (they don't have to be contiguous), so that when you order by SeqNo, your sections will be presented in the correct order on the page.
我担心的一个领域是部分在每个页面的排序——我认为你Page_Section表需要一个额外的列SeqNo SMALLINT NOT NULL将值增加订单(他们不必是连续的),所以当你SeqNo顺序,你的部分会呈现在页面上以正确的顺序。
You might need a similar sequencing column for fields within a section.
您可能需要一个类似的排序列用于一个区段中的字段。
Your Field table will probably need some field type information.
您的字段表可能需要一些字段类型信息。
Maybe your FieldValue table should be renamed to PageFieldValue; it is designed to associate a value with the field on a particular page. As long as a given field can't appear more than once on a page, the renamed table is accurately named; it contains the value of a field on the nominated page. It isn't clear whether there can be some sort of default system so that if a page doesn't specify a particular value for a field, then the default value kicks in. It might be worth thinking about.
也许您的FieldValue表应该重命名为PageFieldValue;它被设计成将一个值与特定页面上的字段相关联。只要给定字段在页面上出现不超过一次,重命名的表就会被正确命名;它包含指定页面上字段的值。目前还不清楚是否存在某种默认系统,因此,如果页面没有为字段指定特定的值,那么默认值就会出现。这可能值得考虑。
#2
1
My big question would be, What is it that you are trying to record? Is the point to record the aassignment of fields to sections and sections to pages? Or is the point to record business data that just happens to be split across multiple sections and pages because of limits of screen size, etc?
我最大的问题是,你想记录的是什么?是否要将字段分配到节,节分配到页?或者,记录业务数据的目的是由于屏幕大小等限制而在多个部分和页面上进行分割吗?
For example, suppose on page 1 we have, say, customer name and address, and on page 2 we have account number and phone number. If tomorrow someone were to redesign the screen to move the account number to page 1, then your present database would require major data updates to move all the field records for account numbers from page 2 to page 1. If this is important to whatever you want to do with the data, like if you want to query "get me a list of all the fields on page 3", then that's simply how it is, and your design here is a good one. But if the association of fields to pages is just a coincidental fact, and not something you would care about in queries, then you're heading in the wrong direction. If that's the case, I would leave out everything about pages and sections and instead think of the business objects about which you are collecting data, like customers and stores and products or whatever it is.
例如,假设在第1页,我们有客户名称和地址,在第2页我们有帐号和电话号码。如果明天有人要重新设计屏幕,将帐户号移动到第1页,那么您当前的数据库将需要重大数据更新,以便将帐户号的所有字段记录从第2页移动到第1页。如果这对你想要处理的数据很重要,比如你想要查询“给我一个第3页上所有字段的列表”,那么这就是你的设计。但是如果字段与页面的关联只是一个巧合的事实,而不是您在查询中关心的内容,那么您就会朝着错误的方向前进。如果是这样的话,我将省略有关页面和部分的所有内容,而是考虑您正在收集数据的业务对象,如客户、商店和产品或其他内容。
That is, is this a "screen layout database", or is it a "customer information database" or "product database" or some such? If it's a screen layout database, then you're on the right track. If it's a product database, then you're on the wrong track.
也就是说,这是一个“屏幕布局数据库”,还是一个“客户信息数据库”或“产品数据库”?如果它是一个屏幕布局数据库,那么您就走对了路。如果它是一个产品数据库,那么您就走错了路。
#3
0
Depending on the applications, if a section has fixed fields and is frequently accessed, you can perform denormalization for that section to improve the query performance. In a way, you can create a table section_x:
根据应用程序的不同,如果一个区段有固定的字段并且经常被访问,您可以为该区段执行非规范化,以改进查询性能。在某种程度上,您可以创建一个表section_x:
section_x
field_1
field_2
...
field_n
You can find more about denormalization on this wiki page: https://en.wikipedia.org/wiki/Denormalization
您可以在这个wiki页面上找到更多关于非规范化的信息:https://en.wikipedia.org/wiki/Denormalization