MySQL - 基于历史增长的家谱预测增长

时间:2016-10-22 17:34:10

标签: mysql

给定一个MySQL表,使用Person,BirthDate和Parent来跟踪家谱的增长情况如何预测从现在开始的1年,3年,10年,50年后家族树的样子?

这是基本的表结构:

    CREATE TABLE FamilyTree (
      PersonID int NOT NULL AUTO_INCREMENT,
      Birthdate DATETIME NOT NULL,
      ParentID int NOT NULL,
      PRIMARY KEY (PersonID)
    );

以下是填充FamilyTree的历史数据:

    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (87, '2016-09-01', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (1, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (2, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (3, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (4, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (5, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (6, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (7, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (8, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (9, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (10, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (11, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (12, '2016-09-02', 87)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (79, '2016-09-05', 3)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (80, '2016-09-05', 1)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (81, '2016-09-05', 1)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (82, '2016-09-05', 2)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (83, '2016-09-05', 2)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (84, '2016-09-05', 2)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (85, '2016-09-05', 119)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (86, '2016-09-05', 3)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (88, '2016-09-05', 150)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (89, '2016-09-05', 4)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (90, '2016-09-05', 4)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (93, '2016-09-05', 4)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (94, '2016-09-05', 93)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (95, '2016-09-05', 147)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (96, '2016-09-05', 123)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (97, '2016-09-05', 104)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (98, '2016-09-05', 5)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (99, '2016-09-05', 124)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (100, '2016-09-05', 5)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (101, '2016-09-05', 98)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (102, '2016-09-05', 90)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (103, '2016-09-05', 120)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (104, '2016-09-05', 6)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (105, '2016-09-06', 90)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (107, '2016-09-06', 6)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (108, '2016-09-06', 119)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (110, '2016-09-06', 116)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (111, '2016-09-06', 6)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (112, '2016-09-06', 111)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (113, '2016-09-06', 110)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (114, '2016-09-06', 90)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (115, '2016-09-06', 7)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (116, '2016-09-06', 119)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (117, '2016-09-06', 7)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (118, '2016-09-06', 100)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (119, '2016-09-06', 7)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (120, '2016-09-06', 119)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (121, '2016-09-06', 110)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (122, '2016-09-06', 7)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (123, '2016-09-06', 130)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (124, '2016-09-06', 8)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (125, '2016-09-06', 119)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (126, '2016-09-06', 99)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (127, '2016-09-06', 8)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (128, '2016-09-06', 122)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (129, '2016-09-06', 119)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (130, '2016-09-06', 1)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (131, '2016-09-06', 124)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (132, '2016-09-06', 8)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (133, '2016-09-06', 9)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (134, '2016-09-06', 94)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (135, '2016-09-06', 9)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (136, '2016-09-06', 90)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (137, '2016-09-06', 1344)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (138, '2016-09-06', 93)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (139, '2016-09-06', 128)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (140, '2016-09-06', 119)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (141, '2016-09-06', 136)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (142, '2016-09-06', 9)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (143, '2016-09-06', 128)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (144, '2016-09-06', 86)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (145, '2016-09-06', 146)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (146, '2016-09-06', 10)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (147, '2016-09-06', 119)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (148, '2016-09-06', 10)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (149, '2016-09-06', 99)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (150, '2016-09-06', 3)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (151, '2016-09-06', 99)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (152, '2016-09-06', 129)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (153, '2016-09-07', 190)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (154, '2016-09-07', 151)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (155, '2016-09-07', 119)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (156, '2016-09-07', 93)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (157, '2016-09-07', 151)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (158, '2016-09-07', 122)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (159, '2016-09-07', 147)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (160, '2016-09-07', 11)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (161, '2016-09-07', 146)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (162, '2016-09-07', 118)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (163, '2016-09-07', 99)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (164, '2016-09-07', 146)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (165, '2016-09-07', 151)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (166, '2016-09-07', 145)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (169, '2016-09-07', 121)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (170, '2016-09-07', 146)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (171, '2016-09-07', 125)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (172, '2016-09-07', 165)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (173, '2016-09-07', 145)
    INSERT INTO FamilyTree (PersonID, Birthdate, ParentID) VALUES (174, '2016-09-07', 161)

0 个答案:

没有答案