Course Hero Logo

q2.sql - - Setup. DO NOT REMOVE. .headers on .separator ...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 7 pages.

-- Setup. DO NOT REMOVE..headers on.separator ','DROP TABLE IF EXISTS sets;DROP TABLE IF EXISTS themes;DROP TABLE IF EXISTS parts;DROP VIEW IF EXISTS top_level_themes;DROP VIEW IF EXISTS sets_years;DROP TABLE IF EXISTS parts_fts;-- ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ---- (a.i) Create tables-- [insert your SQL statement(s) BELOW this line]CREATE TABLE sets(set_num TEXT,name TEXT,year INT,theme_id INT,num_parts INT);CREATE TABLE themes(id INT,name TEXT,parent_id INT);CREATE TABLE parts(part_num TEXT,name TEXT,part_cat_id INT,part_material_id INT);-- [insert your SQL statement(s) ABOVE this line]-- [the following statement(s) are for autograding. DO NOTREMOVE.].tables.print '~~~~~'
-- ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ---- (a.ii) Import data-- [insert your SQLite command(s) BELOW this line].import data/sets.csv sets.import data/parts.csv parts.import data/themes.csv themes-- [insert your SQLite command(s) ABOVE this line]-- [the following statement(s) are for autograding. DO NOTREMOVE.].headers offSELECT count(*) FROM sqlite_master WHERE type='table' ANDname='sets';SELECT count(*) FROM sqlite_master WHERE type='table' ANDname='parts';SELECT count(*) FROM sqlite_master WHERE type='table' ANDname='themes';.headers on.print '~~~~~'-- ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ---- (b) Create indexes-- [insert your SQL statement(s) BELOW this line]CREATE INDEX sets_index on sets(set_num);CREATE INDEX parts_index on parts(part_num);CREATE INDEX themes_index on themes(id);-- [insert your SQL statement(s) ABOVE this line]-- [the following statement(s) are for autograding. DO NOTREMOVE.].indexes.print '~~~~~'-- ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** --

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 7 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
PostgreSQL

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture