以下是JSON文件...將JSON轉換爲MySQL表,該表的結構應該如何?
{
"name":"Magic 2014 Core Set",
"code":"M14",
"releaseDate":"2013-07-19",
"border":"black",
"type":"core",
"cards":
[
{
"layout":"normal",
"type":"Creature - Human Warrior",
"types":["Creature"],
"colors":["Red"],
"multiverseid":370735,
"name":"Academy Raider",
"subtypes":["Human","Warrior"],
"cmc":3,
"rarity":"Common",
"artist":"Karl Kopinski",
"power":"1",
"toughness":"1",
"manaCost":"{2}{R}",
"text":"Intimidate (This creature can't be blocked except by artifact creatures and/or creatures that share a color with it.)\n\nWhenever Academy Raider deals combat damage to a player, you may discard a card. If you do, draw a card.",
"number":"124",
"imageName":"academy raider"
},
{
"layout":"normal",
"type":"Artifact - Equipment",
"types":["Artifact"],
"colors":[],
"multiverseid":370581,
"name":"Accorder's Shield",
"subtypes":["Equipment"],
"cmc":0,
"rarity":"Uncommon",
"artist":"Alan Pollack",
"manaCost":"{0}",
"text":"Equipped creature gets +0/+3 and has vigilance. (Attacking doesn't cause it to tap.)\n\nEquip {3} ({3}: Attach to target creature you control. Equip only as a sorcery.)",
"flavor":"An Auriok shield is polished to a mirror finish even on the inside, enabling its bearer to watch foes ahead and behind.",
"number":"204",
"imageName":"accorder's shield"
},
{
"layout":"normal",
"type":"Creature - Spirit",
"types":["Creature"],
"colors":["Black"],
"multiverseid":370811,
"name":"Accursed Spirit",
"subtypes":["Spirit"],
"cmc":4,
"rarity":"Common",
"artist":"Kev Walker",
"power":"3",
"toughness":"2",
"manaCost":"{3}{B}",
"text":"Intimidate (This creature can't be blocked except by artifact creatures and/or creatures that share a color with it.)",
"flavor":"Many have heard the slither of dragging armor and the soft squelch of its voice. But only its victims ever meet its icy gaze.",
"number":"83",
"imageName":"accursed spirit"
},
{...},
{...},
{...},
]
}
該卡數據本身我覺得這是在一個單一的表,但我不知道怎麼...
"name":"Magic 2014 Core Set",
"code":"M14",
"releaseDate":"2013-07-19",
"border":"black",
"type":"core",
會與卡數據相關聯。我應該如何設計MySQL表以實現簡單高效的訪問?
這不是一個答案,所以它是一個評論 - 但是MySQL的要求?或者您認爲這是存儲數據的最佳方式嗎?像Couch這樣的Postgres和noSQL解決方案處理JSON要好得多。 – Interrobang
http://dba.stackexchange.com/ –
@Interrobang MySQL是一項要求。 – rotaercz