Skip to content

Christina Kopecky#83

Open
ckopecky wants to merge 4 commits intobloominstituteoftechnology:masterfrom
ckopecky:master
Open

Christina Kopecky#83
ckopecky wants to merge 4 commits intobloominstituteoftechnology:masterfrom
ckopecky:master

Conversation

@ckopecky
Copy link

@ckopecky ckopecky commented Sep 7, 2018

  • Add a file called queries.sql that runs all of the CREATE TABLE,
    INSERT, and SELECT queries, below.

Details

  • Write CREATE TABLE statements for these relationships:

    • 1. organization. This table should at least have column(s):

      • name
    • 2. channel. This table should at least have column(s):
      * name

    • 3. user. This table should at least have column(s):
      * name

    • 4. message. This table should have at least columns(s):

                  * `post_time`--the timestamp of when the message was posted
                  * `content`--the message content itself
      
  • Add additional foreign keys needed to the above tables, if any.

  • Add additional join tables needed, if any.

  • Write INSERT queries to add information to the database.

  • 1. One organization, Lambda School

  • 2. Three users, Alice, Bob, and Christina

  • 3. Two channels, #general and #random

  • 4. 10 messages (at least one per user, and at least one per channel).

  • 5. Alice should be in #general and #random.

  • 6. Bob should be in #general.

  • 7. Christina should be in #random.

  • Write SELECT queries to:

    • 1. List all organization names.

    • 2. List all channel names.

    • 3. List all channels in a specific organization by organization name.

    • 4. List all messages in a specific channel by channel name #general in
      order of post_time, descending. (Hint: ORDER BY. Because your
      INSERTs might have all taken place at the exact same time, this might
      not return meaningful results. But humor us with the ORDER BY anyway.)

    • 5. List all channels to which user Alice belongs.

    • 6. List all users that belong to channel #general.

    • 7. List all messages in all channels by user Alice.

    • 8. List all messages in #random by user Bob.

    • 9. List the count of messages across all channels per user. (Hint:
      COUNT, GROUP BY.)

    • 10. The title of the user's name column should be User Name and the title of
      the count column should be Message Count. (The SQLite commands
      .mode column and .header on might be useful here.)

    • 11. The user names should be listed in reverse alphabetical order.

      Example:

      User Name   Message Count
      ----------  -------------
      Christina       4
      Bob         3
      Alice       3
      
  • What SQL keywords or concept would you use if you wanted to automatically
    delete all messages by a user if that user were deleted from the user
    table?


[Stretch!] List the count of messages per user per channel.

   Example:

   ```
   User        Channel     Message Count
   ----------  ----------  -------------
   Alice       #general    1
   Bob         #general    1
   Chris       #general    2
   Alice       #random     2
   Bob         #random     2
   Chris       #random     2
   ```

ckopecky added 4 commits September 7, 2018 08:03
Stretch done

Last question answered

LAST SPRINT DONE!
Copy link

@JohnJustinn JohnJustinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thorough work showing mastery of the topic. Very impressive!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants