Database schema:

CREATE TABLE "postHistory" (
	"Id" INTEGER NOT NULL -- example: ['2', '1'],
	"PostHistoryTypeId" INTEGER -- Post History Type Id, example: ['2', '1'],
	"PostId" INTEGER -- Post Id, example: ['2', '1'],
	"RevisionGUID" TEXT -- Revision GUID, example: ['e58bf7fd-e60f-4c58-a6e4-dfc91cf98a69', '18bf9150-f1cb-432d-b7b7-26d2f8e33581'],
	"CreationDate" DATETIME -- Creation Date, example: ['2010-07-19 19:12:12', '2010-07-19 19:12:57'],
	"UserId" INTEGER -- User Id, example: ['24', '8'],
	"Text" TEXT -- example: ['Eliciting priors from experts', 'How should I elicit prior distributions from exper'],
	"Comment" TEXT -- example: ['', 'edited tags'],
	"UserDisplayName" TEXT -- User Display Name, example: ['', 'user28'],
	PRIMARY KEY ("Id"), 
	CONSTRAINT fk_posthistory_posts FOREIGN KEY("PostId") REFERENCES posts ("Id"),
	CONSTRAINT fk_posthistory_users FOREIGN KEY("UserId") REFERENCES users ("Id"),
	UNIQUE ("Id")
)


CREATE TABLE "postLinks" (
	"Id" INTEGER NOT NULL -- example: ['108', '145'],
	"CreationDate" DATETIME -- Creation Date, example: ['2010-07-23 16:30:41', '2010-07-21 14:47:33'],
	"PostId" INTEGER -- Post Id, example: ['548', '395'],
	"RelatedPostId" INTEGER -- Related Post Id, example: ['539', '173'],
	"LinkTypeId" INTEGER -- Link Type Id, example: ['1', '3'],
	PRIMARY KEY ("Id"), 
	CONSTRAINT fk_postlinks_posts FOREIGN KEY("PostId") REFERENCES posts ("Id"),
	CONSTRAINT fk_postlinks_posts FOREIGN KEY("RelatedPostId") REFERENCES posts ("Id")
)


CREATE TABLE badges (
	"Id" INTEGER NOT NULL -- example: ['2', '1'],
	"UserId" INTEGER -- User Id, example: ['5', '6'],
	"Name" TEXT -- example: ['Teacher', 'Student'],
	"Date" DATETIME -- example: ['2010-07-19 19:39:08', '2010-07-19 19:39:07'],
	PRIMARY KEY ("Id"), 
	CONSTRAINT fk_badges_users FOREIGN KEY("UserId") REFERENCES users ("Id")
)


CREATE TABLE comments (
	"Id" INTEGER NOT NULL -- example: ['2', '1'],
	"PostId" INTEGER -- Post Id, example: ['5', '3'],
	"Score" INTEGER -- example: ['5', '0'],
	"Text" TEXT -- example: ["Yes, R is nice- but WHY is it 'valuable'.", 'Could be a poster child fo argumentative and subje'],
	"CreationDate" DATETIME -- Creation Date, example: ['2010-07-19 19:15:52', '2010-07-19 19:16:14'],
	"UserId" INTEGER -- User Id, example: ['13', '37'],
	"UserDisplayName" TEXT -- User Display Name, example: ['user28', 'Statprof'],
	PRIMARY KEY ("Id"), 
	CONSTRAINT fk_comments_posts FOREIGN KEY("PostId") REFERENCES posts ("Id"),
	CONSTRAINT fk_comments_users FOREIGN KEY("UserId") REFERENCES users ("Id")
)


CREATE TABLE posts (
	"Id" INTEGER NOT NULL -- example: ['2', '1'],
	"PostTypeId" INTEGER -- Post Type Id, example: ['2', '1'],
	"AcceptedAnswerId" INTEGER -- Accepted Answer Id, example: ['15', '59'],
	"CreaionDate" DATETIME -- Creation Date, example: ['2010-07-19 19:12:12', '2010-07-19 19:12:57'],
	"Score" INTEGER -- example: ['23', '22'],
	"ViewCount" INTEGER -- View Count, example: ['8198', '1278'],
	"Body" TEXT -- example: ['<p>How should I elicit prior distributions from ex', '<p>In many different statistical methods there is '],
	"OwnerUserId" INTEGER -- Owner User Id, example: ['24', '8'],
	"LasActivityDate" DATETIME -- Last Activity Date, example: ['2012-11-12 09:21:54', '2010-09-15 21:08:26'],
	"Title" TEXT -- example: ['What is normality?', 'Eliciting priors from experts'],
	"Tags" TEXT -- example: ['<bayesian><prior><elicitation>', '<distributions><normality>'],
	"AnswerCount" INTEGER -- Answer Count, example: ['5', '7'],
	"CommentCount" INTEGER -- Comment Count, example: ['1', '4'],
	"FavoriteCount" INTEGER -- Favorite Count, example: ['14', '8'],
	"LastEditorUserId" INTEGER -- Last Editor User Id, example: ['88', '183'],
	"LastEditDate" DATETIME -- Last Edit Date, example: ['2010-08-07 17:56:44', '2011-02-12 05:50:03'],
	"CommunityOwnedDate" DATETIME -- Community Owned Date, example: ['2010-07-19 19:14:43', '2010-07-19 19:13:28'],
	"ParentId" INTEGER -- example: ['7', '3'],
	"ClosedDate" DATETIME -- Closed Date, example: ['2010-07-19 20:19:46', '2010-08-05 13:06:12'],
	"OwnerDisplayName" TEXT -- Owner Display Name, example: ['user28', 'user209'],
	"LastEditorDisplayName" TEXT -- Last Editor Display Name, example: ['user10525', 'user28'],
	PRIMARY KEY ("Id"), 
	CONSTRAINT fk_posts_users FOREIGN KEY("LastEditorUserId") REFERENCES users ("Id"),
	CONSTRAINT fk_posts_users FOREIGN KEY("OwnerUserId") REFERENCES users ("Id"),
	CONSTRAINT fk_posts_posts FOREIGN KEY("ParentId") REFERENCES posts ("Id"),
	UNIQUE ("Id")
)


CREATE TABLE tags (
	"Id" INTEGER NOT NULL -- example: ['2', '1'],
	"TagName" TEXT -- Tag Name, example: ['bayesian', 'prior'],
	"Count" INTEGER -- example: ['1342', '168'],
	"ExcerptPostId" INTEGER -- Excerpt Post Id, example: ['20258', '62158'],
	"WikiPostId" INTEGER -- Wiki Post Id, example: ['20257', '62157'],
	PRIMARY KEY ("Id"), 
	CONSTRAINT fk_tags_posts FOREIGN KEY("ExcerptPostId") REFERENCES posts ("Id")
)


CREATE TABLE users (
	"Id" INTEGER NOT NULL -- example: ['2', '-1'],
	"Reputation" INTEGER -- example: ['1', '101'],
	"CreationDate" DATETIME -- Creation Date, example: ['2010-07-19 06:55:26', '2010-07-19 14:01:36'],
	"DisplayName" TEXT -- Display Name, example: ['Geoff Dalgas', 'Community'],
	"LastAccessDate" DATETIME -- Last Access Date, example: ['2010-07-19 06:55:26', '2013-11-12 22:07:23'],
	"WebsiteUrl" TEXT -- Website Url, example: ['http://stackoverflow.com', 'http://meta.stackexchange.com/'],
	"Location" TEXT -- example: ['Corvallis, OR', 'on the server farm'],
	"AboutMe" TEXT -- About Me, example: ["<p>Hi, I'm not really a person.</p>\n\n<p>I'm a back", '<p>Developer on the StackOverflow team.  Find me o'],
	"Views" INTEGER -- example: ['0', '25'],
	"UpVotes" INTEGER -- example: ['5007', '3'],
	"DownVotes" INTEGER -- example: ['1920', '0'],
	"AccountId" INTEGER -- Account Id, example: ['2', '-1'],
	"Age" INTEGER -- example: ['35', '37'],
	"ProfileImageUrl" TEXT -- Profile Image Url, example: ['http://i.stack.imgur.com/d1oHX.jpg', 'http://i.stack.imgur.com/km1pr.jpg'],
	PRIMARY KEY ("Id"), 
	UNIQUE ("Id")
)


CREATE TABLE votes (
	"Id" INTEGER NOT NULL -- example: ['2', '1'],
	"PostId" INTEGER -- Post Id, example: ['2', '3'],
	"VoteTypeId" INTEGER -- Vote Type Id, example: ['2', '5'],
	"CreationDate" DATE -- Creation Date, example: ['2010-07-19', '2010-07-20'],
	"UserId" INTEGER -- User Id, example: ['58', '6'],
	"BountyAmount" INTEGER -- Bounty Amount, example: ['50', '25'],
	PRIMARY KEY ("Id"), 
	CONSTRAINT fk_votes_posts FOREIGN KEY("PostId") REFERENCES posts ("Id"),
	CONSTRAINT fk_votes_users FOREIGN KEY("UserId") REFERENCES users ("Id")
)

Question: How many badges has the user csgillespie obtained?
Evidence: "csgillespie" is the DisplayName of user

SQL:
SELECT COUNT(T1.Id) FROM badges AS T1 INNER JOIN users AS T2 ON T1.UserId = T2.Id WHERE T2.DisplayName = 'csgillespie'