Wladimir Fraga CS10#81
Open
wladimir917 wants to merge 12 commits intobloominstituteoftechnology:masterfrom
Open
Wladimir Fraga CS10#81wladimir917 wants to merge 12 commits intobloominstituteoftechnology:masterfrom
wladimir917 wants to merge 12 commits intobloominstituteoftechnology:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wladimir Fraga CS10
Sprint Challenge: SQL
Design a database for an online chat system.
Deliverables
queries.sqlthat runs all of theCREATE TABLE,INSERT, andSELECTqueries, below.The last question is a fill-in-the-blank. You can add that as a SQL
comment to the end of
queries.sql.Details
CREATE TABLEstatements for tablesorganization,channel,user,and
message.organization. This table should at least have column(s):namechannel. This table should at least have column(s):nameuser. This table should at least have column(s):namemessage. This table should have at least columns(s):post_time--the timestamp of when the message was postedSQLite.
Also see the SQLite function
datetime().content--the message content itselfAdd additional foreign keys needed to the above tables, if any.
Add additional join tables needed, if any.
Write
INSERTqueries to add information to the database.For these
INSERTs, it is OK to refer to users, channels, and organizationby their
ids. No need to do a subselect unless you want to.Lambda SchoolAlice,Bob, andChris#generaland#randomAliceshould be in#generaland#random.Bobshould be in#general.Chrisshould be in#random.Write
SELECTqueries to:For these
SELECTs, it is NOT OK to refer to users, channels, andorganization by their
ids. You must join in those cases.List all organization
names.List all channel
names.List all channels in a specific organization by organization
name.List all messages in a specific channel by channel
name#generalinorder of
post_time, descending. (Hint:ORDER BY. Because yourINSERTs might have all taken place at the exact same time, this mightnot return meaningful results. But humor us with the
ORDER BYanyway.)List all channels to which user
Alicebelongs.List all users that belong to channel
#general.List all messages in all channels by user
Alice.List all messages in
#randomby userBob.List the count of messages across all channels per user. (Hint:
COUNT,GROUP BY.)The title of the user's name column should be
User Nameand the title ofthe count column should be
Message Count. (The SQLite commands.mode columnand.header onmight be useful here.)The user names should be listed in reverse alphabetical order.
Example:
[Stretch!] List the count of messages per user per channel.
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
usertable?