0

我有一个这样的json文件

[
     {

       "topic": "Example1", 
       "ref": {
            "1": "Example Topic", 
            "2": "Topic"
        }, 
       "contact": [
            {
                "ref": [
                    1
                ], 
                "corresponding": true, 
                "name": "XYZ"
            }, 
            {
                "ref": [
                    1
                ], 
                "name": "ZXY"
            }, 
            {
                "ref": [
                    1
                ], 
                "name": "ABC"
            }, 
            {
                "ref": [
                    1, 
                    2
                ], 
                "name":"BCA"
            }
        ] , 

        "type": "Presentation"
     }, 
    {

       "topic": "Example2", 
       "ref": {
            "1": "Example Topic", 
            "2": "Topic"
        }, 
       "contact": [
            {
                "ref": [
                    1
                ], 
                "corresponding": true, 
                "name": "XYZ"
            }, 
            {
                "ref": [
                    1
                ], 
                "name": "ZXY"
            }, 
            {
                "ref": [
                    1
                ], 
                "name": "ABC"
            }, 
            {
                "ref": [
                    1, 
                    2
                ], 
                "name":"BCA"
            }
        ] , 

        "type": "Poster"
     }
]

我创建了3 TablesItems,Reference,Contact 一是

 Items:
    Item_ID
    topic
    type
  reference:
    ref_ID
    content
   Contact:
     ref_ID
     contact_ID
     Item_ID
     name

关系 :

1) Items has many references
2)Items has many Authors
3)Authors has many references

现在,我的问题是

1)我应该在这里做错什么吗?

2)有什么办法可以改善我目前的实施?

3)在这里,我对实现corresponding(在联系人数组内部)感到困惑。我如何在设计中实现它?

谢谢。

4

1 回答 1

1

从您上面的 Json. 中,我可以推断出这个规范化的模式。您在上面的 Json 中有 2 个参考。你能澄清一下吗?

另外,这里有一个对您有用的链接。 http://jsonviewer.stack.hu/在查看器和文本选项卡之间切换。

您的场景中的实际示例是.,

P- Primary Key
Ref - Reference Key


Topic:
--------------------------------------------------
Topic ID (P)  | TopicName            | TypeID (Ref)
----------------------------------------------------
  0               Example1                       0
  1               Example2                       1


TopicReferences :
----------------------------
TopicID (P) | RefernceID (Ref)
--------------------------------
  0                 0
  0                 1
  1                 0
  1                 1

Reference :
------------------------------------
ReferenceID (P)  | ReferenceName 
------------------------------------
  0                 Example Topic
  1                 Topic 

Presentation Type :
--------------------------
TypeID (P) | TypeName 
--------------------------
 0           Presentation
 1           Poster

TopicContacts:
---------------------------------
TopicID  | ContactID   (Ref)
---------------------------------
   0              0
   0              1
   0              2
   0              3
   1              0
   1              1
   1              2
   1              3

Contact:
-------------------------------------------------------------------
ContactID(P)  | ContactName | IsCorresponding ( Boolean, nullable)
------------------------------------------------------------------
   0                XYZ             YES
   1                ZXY             NULL
   2                ABC             NULL
   3                BCA             NULL

ContactsReference2:
--------------------------------------------
ContactID  | Reference2ID  (Ref)
--------------------------------------------
  0                  0
  1                  0
  2                  0
  3                  0
  3                  1

Reference2:
--------------------------------------------
Reference2ID(P)  | Reference2Value (NUM)
--------------------------------------------
   0                         1
   1                         2          
于 2013-07-17T18:54:06.183 回答