b¬äd†ødd

Dedicated to design and performance of databases and audio systems.

MongoDB: inserting test data

Overview:

For many of the code trials I do, one thing that always helps is having a familiar set of data. To maximize its value I try to use a subject area that involves many different data types and has documents that differ.

The Winter Olympics have historical differences. While we think of the games occurring every four years, they did not during WWII and there were only two years between the 1992 Albertville France and the 1994 Lillehammer Norway games. Additionally, events have been added and removed over the years. Lastly, the 2018 games will be in South Korea, but they have not occurred yet.

All of these facets affect the data and individual document structures. Enclosed is one version of the data. Note the differences with the 1940, 1944, 2018, and 2022 documents.

db.olympics.insert( [
    { 
        _id : NumberInt(1), 
	name : "I", 
	year : NumberInt(1924),
	location : { 
		city : "Chamonix", 
		country: "France" 
	}, 
	period : { 
		start : ISODate("1924-01-25"), 
		end : ISODate("1924-02-05") 
	},
	nations : NumberInt(16),
	competitors : {
		total : NumberInt(258),
		men : NumberInt(247),
		women : NumberInt(11)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(9),
	events : NumberInt(16)
    }
    ,
    { 
	_id : NumberInt(2), 
	name : "II", 
	year : NumberInt(1928),
	location : { 
		city : "St. Mortiz", 
		country: "Switzerland" 
	}, 
	period : { 
		start : ISODate("1928-02-11"), 
		end : ISODate("1928-02-19") 
	},
	nations : NumberInt(25),
	competitors : {
		total : NumberInt(464),
		men : NumberInt(438),
		women : NumberInt(26)
	},
	sports : NumberInt(4),
	disciplines : NumberInt(8),
	events : NumberInt(14)
    }
    ,
    { 
	_id : NumberInt(3), 
	name : "III", 
	year : NumberInt(1932),
	location : { 
		city : "Lake Placid", 
		country: "United States" 
	}, 
	period : { 
		start : ISODate("1932-02-04"), 
		end : ISODate("1932-02-15") 
	},
	nations : NumberInt(17),
	competitors : {
		total : NumberInt(252),
		men : NumberInt(231),
		women : NumberInt(21)
	},
	sports : NumberInt(4),
	disciplines : NumberInt(7),
	events : NumberInt(14)
    }
    ,
    { 
	_id : NumberInt(4), 
	name : "IV", 
	year : NumberInt(1936),
	location : { 
		city : "Garmisch-Partenkirchen", 
		country: "Germany" 
	}, 
	period : { 
		start : ISODate("1936-02-06"), 
		end : ISODate("1936-02-16") 
	},
	nations : NumberInt(28),
	competitors : {
		total : NumberInt(646),
		men : NumberInt(566),
		women : NumberInt(80)
	},
	sports : NumberInt(4),
	disciplines : NumberInt(8),
	events : NumberInt(17)
    }
    ,
    {
	year : NumberInt(1940),
	location : {
		city : "Sapporo",
		country : "Japan"
	},
	period : { 
		start : ISODate("1940-02-03"), 
		end : ISODate("1940-02-12") 
	},
	celebrated : false,
	transaction : "returned",
	reason : "Second Sino Japanese War",
	occurred : ISODate("1938-07-01")
    }
    ,
    {
	year : NumberInt(1940),
	location : {
		city : "St. Moritz",
		country : "Switzerland"
	},
	celebrated : false,
	transaction : "withdrawn",
	reason : "Controversies between the Swiss organizing team and the IOC",
	occurred : ISODate("1939-03-01")
    }
    ,
    {
	year : NumberInt(1940),
	location : {
		city : "Garmisch-Partenkirchen",
		country : "Germany"
	},
	celebrated : false,
	transaction : "cancelled",
	reason : "WWII",
	occurred : ISODate("1939-11-01")
    }
    ,
    {
	year : NumberInt(1944),
	location : {
		city : "Cortina d'Ampezzo",
		country : "Italy"
	},
	celebrated : false,
	transaction : "cancelled",
	reason : "WWII",
	occurred : NumberInt(1940)
    }
    ,
    { 
	_id : NumberInt(5), 
	name : "V", 
	year : NumberInt(1948),
	location : { 
		city : "St. Moritz", 
		country: "Switzerland" 
	}, 
	period : { 
		start : ISODate("1948-01-30"), 
		end : ISODate("1948-02-08") 
	},
	nations : NumberInt(28),
	competitors : {
		total : NumberInt(669),
		men : NumberInt(592),
		women : NumberInt(77)
	},
	sports : NumberInt(4),
	disciplines : NumberInt(9),
	events : NumberInt(22)
    }
    ,
    { 
	_id : NumberInt(6), 
	name : "VI", 
	year : NumberInt(1952),
	location : { 
		city : "Oslo", 
		country: "Norway" 
	}, 
	period : { 
		start : ISODate("1952-02-14"), 
		end : ISODate("1952-02-25") 
	},
	nations : NumberInt(30),
	competitors : {
		total : NumberInt(694),
		men : NumberInt(585),
		women : NumberInt(109)
	},
	sports : NumberInt(4),
	disciplines : NumberInt(8),
	events : NumberInt(22)
    }
    ,
    { 
	_id : NumberInt(7), 
	name : "VII", 
	year : NumberInt(1956),
	location : { 
		city : "Cortina d'Amprezzo", 
		country: "Italy" 
	}, 
	period : { 
		start : ISODate("1956-01-26"), 
		end : ISODate("1956-02-05") 
	},
	nations : NumberInt(32),
	competitors : {
		total : NumberInt(821),
		men : NumberInt(687),
		women : NumberInt(134)
	},
	sports : NumberInt(4),
	disciplines : NumberInt(8),
	events : NumberInt(24)
    }
    ,
    { 
	_id : NumberInt(8), 
	name : "VIII", 
	year : NumberInt(1960),
	location : { 
		city : "Squaw Valley", 
		country: "United States" 
	}, 
	period : { 
		start : ISODate("1960-02-18"), 
		end : ISODate("1960-02-28") 
	},
	nations : NumberInt(30),
	competitors : {
		total : NumberInt(665),
		men : NumberInt(521),
		women : NumberInt(144)
	},
	sports : NumberInt(4),
	disciplines : NumberInt(8),
	events : NumberInt(27)
    }
    ,
    { 
	_id : NumberInt(9), 
	name : "IX", 
	year : NumberInt(1964),
	location : { 
		city : "Innsbruck", 
		country: "Austria" 
	}, 
	period : { 
		start : ISODate("1964-01-29"), 
		end : ISODate("1964-02-09") 
	},
	nations : NumberInt(36),
	competitors : {
		total : NumberInt(1091),
		men : NumberInt(892),
		women : NumberInt(199)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(10),
	events : NumberInt(34)
    }
    ,
    { 
	_id : NumberInt(10), 
	name : "X", 
	year : NumberInt(1968),
	location : { 
		city : "Grenoble", 
		country: "France" 
	}, 
	period : { 
		start : ISODate("1968-02-06"), 
		end : ISODate("1968-02-18") 
	},
	nations : NumberInt(37),
	competitors : {
		total : NumberInt(1158),
		men : NumberInt(947),
		women : NumberInt(211)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(10),
	events : NumberInt(35)
    }
    ,
    { 
	_id : NumberInt(11), 
	name : "XI", 
	year : NumberInt(1972),
	location : { 
		city : "Sapporo", 
		country: "Japan" 
	}, 
	period : { 
		start : ISODate("1972-02-03"), 
		end : ISODate("1972-02-13") 
	},
	nations : NumberInt(35),
	competitors : {
		total : NumberInt(1006),
		men : NumberInt(801),
		women : NumberInt(205)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(10),
	events : NumberInt(35)
    }
    ,
    { 
	_id : NumberInt(12), 
	name : "XII", 
	year : NumberInt(1976),
	location : { 
		city : "Innsbruck", 
		country: "Austria" 
	}, 
	period : { 
		start : ISODate("1976-02-04"), 
		end : ISODate("1976-02-15") 
	},
	nations : NumberInt(37),
	competitors : {
		total : NumberInt(1123),
		men : NumberInt(892),
		women : NumberInt(231)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(10),
	events : NumberInt(37)
    }
    ,
    { 
	_id : NumberInt(13), 
	name : "XIII", 
	year : NumberInt(1980),
	location : { 
		city : "Lake Placid", 
		country: "United States" 
	}, 
	period : { 
		start : ISODate("1980-02-13"), 
		end : ISODate("1980-02-24") 
	},
	nations : NumberInt(37),
	competitors : {
		total : NumberInt(1072),
		men : NumberInt(840),
		women : NumberInt(232)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(10),
	events : NumberInt(38)
    }
    ,
    { 
	_id : NumberInt(14), 
	name : "XIV", 
	year : NumberInt(1984),
	location : { 
		city : "Sarajevo", 
		country: "Yugoslavia" 
	}, 
	period : { 
		start : ISODate("1984-02-08"), 
		end : ISODate("1984-02-19") 
	},
	nations : NumberInt(49),
	competitors : {
		total : NumberInt(1272),
		men : NumberInt(998),
		women : NumberInt(274)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(10),
	events : NumberInt(39)
    }
    ,
    { 
	_id : NumberInt(15), 
	name : "XV", 
	year : NumberInt(1988),
	location : { 
		city : "Calgary", 
		country: "Canada" 
	}, 
	period : { 
		start : ISODate("1988-02-13"), 
		end : ISODate("1988-02-28") 
	},
	nations : NumberInt(57),
	competitors : {
		total : NumberInt(1423),
		men : NumberInt(1122),
		women : NumberInt(301)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(10),
	events : NumberInt(46)
    }
    ,
    { 
	_id : NumberInt(16), 
	name : "XVI", 
	year : NumberInt(1992),
	location : { 
		city : "Albertville", 
		country: "France" 
	}, 
	period : { 
		start : ISODate("1992-02-08"), 
		end : ISODate("1992-02-23") 
	},
	nations : NumberInt(64),
	competitors : {
		total : NumberInt(1801),
		men : NumberInt(1313),
		women : NumberInt(488)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(12),
	events : NumberInt(57)
    }
    ,
    { 
	_id : NumberInt(17), 
	name : "XVII", 
	year : NumberInt(1994),
	location : { 
		city : "Lillehammer", 
		country: "Norway" 
	}, 
	period : { 
		start : ISODate("1994-02-12"), 
		end : ISODate("1994-02-27") 
	},
	nations : NumberInt(67),
	competitors : {
		total : NumberInt(1737),
		men : NumberInt(1215),
		women : NumberInt(522)
	},
	sports : NumberInt(6),
	disciplines : NumberInt(12),
	events : NumberInt(61)
    }
    ,
    { 
	_id : NumberInt(18), 
	name : "XVIII", 
	year : NumberInt(1998),
	location : { 
		city : "Nagano", 
		country: "Japan" 
	}, 
	period : { 
		start : ISODate("1998-02-07"), 
		end : ISODate("1998-02-22") 
	},
	nations : NumberInt(72),
	competitors : {
		total : NumberInt(2176),
		men : NumberInt(1389),
		women : NumberInt(787)
	},
	sports : NumberInt(7),
	disciplines : NumberInt(14),
	events : NumberInt(68)
    }
    ,
    { 
	_id : NumberInt(19), 
	name : "XIX", 
	year : NumberInt(2002),
	location : { 
		city : "Salt Lake City", 
		country: "United States" 
	}, 
	period : { 
		start : ISODate("2002-02-08"), 
		end : ISODate("2002-02-24") 
	},
	nations : NumberInt(78),
	competitors : {
		total : NumberInt(2399),
		men : NumberInt(1513),
		women : NumberInt(886)
	},
	sports : NumberInt(7),
	disciplines : NumberInt(15),
	events : NumberInt(78)
    }
    ,
    { 
	_id : NumberInt(20), 
	name : "XX", 
	year : NumberInt(2006),
	location : { 
		city : "Turin", 
		country: "Italy" 
	}, 
	period : { 
		start : ISODate("2006-02-10"), 
		end : ISODate("2006-02-26") 
	},
	nations : NumberInt(80),
	competitors : {
		total : NumberInt(2508),
		men : NumberInt(1548),
		women : NumberInt(960)
	},
	sports : NumberInt(7),
	disciplines : NumberInt(15),
	events : NumberInt(84)
    }
    ,
    { 
	_id : NumberInt(21), 
	name : "XXI", 
	year : NumberInt(2010),
	location : { 
		city : "Vancouver", 
		country: "Canada" 
	}, 
	period : { 
		start : ISODate("2010-02-12"), 
		end : ISODate("2010-02-28") 
	},
	nations : NumberInt(82),
	competitors : {
		total : NumberInt(2566),
		men : NumberInt(1522),
		women : NumberInt(1044)
	},
	sports : NumberInt(7),
	disciplines : NumberInt(15),
	events : NumberInt(86)
    }
    ,
    { 
	_id : NumberInt(22), 
	name : "XXII", 
	year : NumberInt(2014),
	location : { 
		city : "Sochi", 
		country: "Russia" 
	}, 
	period : { 
		start : ISODate("2014-02-07"), 
		end : ISODate("2014-02-23") 
	},
	nations : NumberInt(88),
	competitors : {
		total : NumberInt(2873)
	},
	sports : NumberInt(7),
	disciplines : NumberInt(15),
	events : NumberInt(98)
    }
    ,
    { 
	_id : NumberInt(23), 
	name : "XXIII", 
	year : NumberInt(2018),
	location : { 
		city : "Pyeongchang", 
		country: "South Korea" 
	}, 
	period : { 
		start : ISODate("2018-02-09"), 
		end : ISODate("2018-02-25") 
	},
	nations : NumberInt(90),
	sports : NumberInt(7),
	disciplines : NumberInt(15),
	events : NumberInt(98)
    }
    ,
    {
	_id : NumberInt(24),
	name : "XXIV",
        year : NumberInt(2022),
        location : [
	    {
		city : "Krakow",
		country : "Poland"
	    },
	    {
		city : "Oslo",
		country : "Norway"
	    },
	    {
		city : "Almaty",
		country : "Kazakhstan"
	    },
	    {
		city : "Lviv",
		country : "Ukraine"
	    },
	    {
		city : "Beijing",
		country : "China"
	    }
        ],
	period : [
            { 
	        start : ISODate("2022-02-11"), 
		end : ISODate("2022-02-27") 
	    },
            { 
		start : ISODate("2022-02-11"), 
		end : ISODate("2022-02-27") 
	    },
            { 
		start : ISODate("2022-02-04"), 
		end : ISODate("2022-02-20") 
	    },
            { 
		start : ISODate("2022-02-11"), 
		end : ISODate("2022-02-27") 
	    },
            { 
		start : ISODate("2022-02-04"), 
		end : ISODate("2022-02-20") 
	    },
	],
	selection : ISODate("2015-07-31")
    }
] )