MySQL家谱

时间:2017-02-28 06:31:22

标签: mysql syntax foreign-keys family-tree

Errors Image

有关这些语法错误的任何想法吗?与FOREIGN KEY语法相关?不知道!我删除了ENGINE = INNODB;但是它仍然无效。

DROP TABLE IF EXISTS Marriage;
CREATE TABLE Marriage (
    marriageID int NOT NULL,
    PRIMARY KEY(marriageID),
    date DATE,
    place varchar(100)
);

最好的一个正常 - 真正的麻烦从下一个的外国钥匙开始:

DROP TABLE IF EXISTS MarriagePerson;
CREATE TABLE MarriagePerson (
    marriagePersonID int NOT NULL,
    marriageID int,
    personID int,
    PRIMARY KEY(marriagePersonID),  
    FOREIGN KEY marriageID REFERENCES Marriage(marriageID),
    FOREIGN KEY personID REFERENCES Person(personID)
);

DROP TABLE IF EXISTS Person;
CREATE TABLE Person (
     personID int NOT NULL,
     PRIMARY KEY(personID),
     firstName varchar(100),
     lastName varchar(100),
     gender  ENUM(male, female, nonBinary),
     birthDate DATE,
     birthPlace varchar(100),
     deathDate DATE,
     deathPlace varchar(100),
     causeOfDeath varchar(100),
     note varchar(1000)
) ENGINE=InnoDB;

DROP TABLE IF EXISTS Parent;
CREATE TABLE Parent (
    parentID int NOT NULL,
    PRIMARY KEY(parentID),
    FOREIGN KEY personID int,
    FOREIGN KEY parentPersonID int,
    relationship ENUM(sperm, egg)
) ENGINE=InnoDB;

1 个答案:

答案 0 :(得分:1)

如果您按照发布的顺序运行它,

在第二个查询中,您有:

Option Explicit

Sub ChartFormattingVlookup()

    Dim mySeries As Series
    Dim cht As ChartObject
    Dim vbc As Range

    Set vbc = Worksheets("VBAChartFormat").Range("A2:I44")

    For Each cht In ActiveSheet.ChartObjects
        For Each mySeries In cht.SeriesCollection
            With mySeries
                If Not IsError(Application.VLookup(mySeries.Name, vbc, 7, False)) Then '<-- check VLookup was successfull
                    .MarkerSize = Application.VLookup(mySeries.Name, vbc, 7, False)
                End If
                If Not IsError(Application.VLookup(mySeries.Name, vbc, 6, False)) Then '<-- check VLookup was successfull
                    .MarkerSize = Application.VLookup(mySeries.Name, vbc, 6, False)
                End If
            End With
        Next mySeries
    Next cht

End Sub

尚未创建。 Person表在下一个查询中创建。