0

我有一个名为服务条目的表。在一个服务条目中可能有多个部分。所以表服务入口部分的每个部分都会有一行。零件存储在零件表中。服务条目表有一个逗号分隔的列,其中包含用于在页面上显示的部件信息。

Dbo.Part

ID   PartDescription
270  Syringe assembly
282  LPH pcb 
287  Valve block assembly 

Dbo.ServiceEntry

ServiceEntryID, Description
     1200         270 ~ Syringe assembly  ~ 7,3 ~ Increase drive current from 3 --> 1.|282 ~ LPH pcb ~ 8 ~  | 287 ~ Valve block
   assembly ~ null ~

在上面这里是列的结构:

PartID ~ PartDescription ~ ServiceType ~ Comment

对于多个部分,添加此字符|并重复结构。

ServiceEntryPart

ID  ServiceEntryID   PartID  ServiceTypev Comment
1    1200            270      7,3         Increase drive current from 3
2    1200            282      8          
3    1200            287      null    

问题

Dbo.Part

ID   PartDescription       OldID
331  Syringe assembly      270
335  LPH pcb               282
336  Valve block assembly  287

因此,如果您查看上面的零件表,发生的事情是零件表正在更新。将添加新部件,对于现有部件,它们的 id 将更新为新 id,并且可能会有新的部件描述。如您所见,带有列部分描述的服务条目表将不会与之前创建的服务条目同步。我要做的是使用新的部件 ID 及其 dcescriptions 更新现有的服务条目部件表,最后更新服务条目表中称为部件描述的列。更新服务条目部分表很简单,但问题是如何更新服务条目表中的分隔列。

4

1 回答 1

0

如果我理解正确,您正在使用包含多个分隔值的列(如 PICK 数据库):

`For multiple parts, this character | is added and the structure is repeated.`

通常,在规范化数据库中,会有:

UNIT  (something that might need service or repair)
UnitId  PK
UnitDescription

PARTS  (repair / replacement parts)
PartId PK
PartDescription

UNIT_SERVICES  (instances of repair visits/ service)
ServiceID   int primary key
UnitId      foreign key references UNIT
ServiceDate
TechnicianID
etc


SERVICE_PART   (part used in the service)
ID          primary key
ServiceID   foreign key references SERVICE
PartID      foreign key references PART
Quantity

与一个 UNIT 相关联的 UNIT_SERVICES 可能有零个、一个或多个。可以有零个、一个或多个与 SERVICE 关联的 SERVICE_PARTS。

在规范化数据库中,用于为一个单元提供服务的每个部分都将存在于 SERVICE_PART 表中自己的行中。我们不会在同一个 SERVICE_PART 元组中找到两个或多个部分,它们由一些分隔符分隔,就像在现代 OODBMS 的前身所谓的多值数据库中通常所做的那样。

于 2013-02-12T21:45:27.757 回答