Skip to content

Commit 6aaaf9c

Browse files
Transposed Startup scripts from MS SQL to MySQL
1 parent 023b8ee commit 6aaaf9c

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

alexander_connelly_code_challenge.txt

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,23 @@ Data Integrity Checking & Cleanup
44

55
- For all countries that have multiple rows in the continent_map table, delete all multiple records leaving only the 1 record per country. The record that you keep should be the first one when sorted by the continent_code alphabetically ascending. Provide the query/ies and explanation of step(s) that you follow to delete these records.
66

7-
CREATE DATABASE BrainTreeSQLCodingChallenge
8-
9-
CREATE TABLE continent_map (
10-
ID int IDENTITY (1 , 1) PRIMARY KEY ,
11-
country_code nvarchar(3),
12-
continent_code nvarchar(2)
13-
);
14-
CREATE TABLE continents (
15-
continent_code nvarchar(2),
16-
continent_name nvarchar(50)
17-
);
18-
CREATE TABLE countries (
19-
country_code nvarchar(3),
20-
country_name nvarchar(100)
21-
);
22-
CREATE TABLE per_capita (
23-
country_code nvarchar(3),
24-
year int,
25-
gdp_per_capita float
26-
);
27-
28-
# Used Flat File Import to Get CSV files into DB Tables
7+
CREATE DATABASE BrainTree
298

9+
CREATE TABLE `braintree`.`continent_map` (`country_code` text, `continent_code` text);
10+
PREPARE stmt FROM 'INSERT INTO `braintree`.`continent_map` (`continent_code`,`country_code`) VALUES(?,?)'
11+
DEALLOCATE PREPARE stmt
12+
13+
CREATE TABLE `braintree`.`continents` (`continent_code` text, `continent_name` text)
14+
PREPARE stmt FROM 'INSERT INTO `braintree`.`continents` (`continent_name`,`continent_code`) VALUES(?,?)'
15+
DEALLOCATE PREPARE stmt
16+
17+
CREATE TABLE `braintree`.`countries` (`country_code` text, `country_name` text)
18+
PREPARE stmt FROM 'INSERT INTO `braintree`.`countries` (`country_name`,`country_code`) VALUES(?,?)'
19+
DEALLOCATE PREPARE stmt
20+
21+
CREATE TABLE `braintree`.`per_capita` (`country_code` text, `year` int, `gdp_per_capita` double)
22+
PREPARE stmt FROM 'INSERT INTO `braintree`.`per_capita` (`gdp_per_capita`,`country_code`,`year`) VALUES(?,?,?)'
23+
DEALLOCATE PREPARE stmt
3024

3125
SELECT COALESCE([country_code],'FOO')
3226

0 commit comments

Comments
 (0)