Skip to content

Instantly share code, notes, and snippets.

@mattmarcello
Last active August 29, 2015 14:07
Show Gist options
  • Save mattmarcello/20e1f06817c05c3046ce to your computer and use it in GitHub Desktop.
Save mattmarcello/20e1f06817c05c3046ce to your computer and use it in GitHub Desktop.
# Connect to the sportz_teams database
# Define a Player class?
# Define a Team class?
# *** ^ Using ActiveRecord? ^ ***
# -- Mutation: Modifying Data
# INSERT INTO teams (name, location, slogan) VALUES ('Lemurs', 'Madagascar Bay', 'Time to climb de fence');
# INSERT INTO teams (name, location, slogan) VALUES ('Racoons', 'Jersey', 'Awwwwwwww... No.');
# INSERT INTO teams (name, location, slogan) VALUES ('Cheddarsaurs', 'Vermont', 'Time to Smile');
# INSERT INTO teams (name, location, slogan) VALUES ('Sailers', 'Atlanic', 'Red sky all day...');
# *** ^ Using ActiveRecord? ^ ***
# -- Selection: Obtaining data
# SELECT * FROM teams;
# *** ^ Using ActiveRecord? ^ ***
# -- Mutation: Modifying Data
# INSERT INTO players (name, age) VALUES ('Lichard DeGray', 3);
# INSERT INTO players (name, age) VALUES ('Kathew Bod', 4);
# INSERT INTO players (name, age) VALUES ('Omily', 7);
# INSERT INTO players (name, age) VALUES ('Willip', 5);
# INSERT INTO players (name, age) VALUES ('Pauldric', 5);
# *** ^ Using ActiveRecord? ^ ***
# -- Selection: Obtaining data
# SELECT * FROM players;
# *** ^ Using ActiveRecord? ^ ***
# -- Selection: Obtaining data
# SELECT * FROM players;
# *** ^ Using ActiveRecord? ^ ***
# -- Mutation: Modifying Data
# UPDATE players SET team_id=(SELECT id FROM teams WHERE name='Lemurs')
# WHERE name='Lichard DeGray';
# UPDATE players SET team_id=(SELECT id FROM teams WHERE name='Racoons')
# WHERE name='Kathew Bod';
# UPDATE players SET team_id=(SELECT id FROM teams WHERE name='Racoons')
# WHERE name='Kathew Bod';
# UPDATE players SET team_id=(SELECT id FROM teams WHERE name='Cheddarsaurs')
# WHERE name='Omily';
# UPDATE players SET team_id=(SELECT id FROM teams WHERE name='Lemurs')
# WHERE name='Willip';
# *** ^ Using ActiveRecord? ^ ***
# -- Selection: Obtaining data
# SELECT * FROM players WHERE team_id=(SELECT id FROM teams WHERE location='Madagascar Bay');
# SELECT * FROM players WHERE team_id=(SELECT id FROM teams WHERE name='Racoons');
# *** ^ Using ActiveRecord? ^ ***
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment