This repository is a quick way to demo the SQL queries for the DotAlign code challenge.
Given the documented database tables (with some sample data) write a SQL query that...
- ... lists of each domain in the system
- ... lists of each email address along with the owner’s real name
- ... lists each domain and the total number of emails sent to it (combining To, CC, & BCC)
In terminal
- clone this repository with
git clone '[email protected]:SammySteiner/dot-align-sql.git' - cd into this directory
cd dot-align-sql
While using a mac: - if you do not have an up-to-date version of Ruby, you may need to update. If you have homebrew installed you can run
brew install ruby - If you do not have the bundler gem installed, run
gem install bundler - If you do not have the sqlite3 gem installed, run
gem install sqlite3
If any of these steps gives you an error, you may not have the right permissions, reach out to me. - run
bundle installto install the required gems - run
ruby bin/create_and_seed_db.rbto create and seed the Database
You're now ready to test out the query files. If you're using Windows, reach out and we'll find a way to set you up to run these files.
To view a printout in terminal of the sql queries, input the following commands:
- ruby lib/sql_query_one.rb
- ruby lib/sql_query_two.rb
- ruby lib/sql_query_three.rb
The SQL queries for each of the challenges are:
- SELECT * FROM domain;
- SELECT email_address.address_text, person.name
FROM email_address
JOIN person ON email_address.person_id == person.id; - SELECT domain.url_text, COUNT(*) as total_sent
FROM domain
JOIN email_address ON domain.id == email_address.domain_id
JOIN participant ON email_address.id == participant.email_address_id
WHERE participant.participant_type_id == 2
OR participant.participant_type_id == 3
OR participant.participant_type_id == 4
GROUP BY domain.url_text;