anthonydb / practical-sql

Code and Data for the First Edition of "Practical SQL" by Anthony DeBarros, published by No Starch Press (2018).
Other
660 stars 406 forks source link

Inclusion of COPY statements in DDL files prevents readers from simply loading them. #1

Open jberkus opened 7 years ago

jberkus commented 7 years ago

Hey, your tech reviewer here.

Example: https://github.com/anthonydb/practical-sql/blob/master/Chapter_08/Chapter_08.sql

The COPY statements are interspersed with table definition statements. The problem with this is that the COPY statements are going to be specific the the reader's OS and where they saved the files. This prevents the reader from simply running the file using PSQL or pgAdmin.

I suggest instead putting the example COPY statements in there, commented out.

anthonydb commented 7 years ago

Hey, Josh! 👋

So, you're saying to comment out all the COPY statements in these .sql files so that a reader could create all the tables at once by running the whole script? In that case, do you recommend separating the CREATE TABLE statements from the SELECT statement listings also in the file?

jberkus commented 7 years ago

Yeah, I was just realizing that all of the select queries are in one file, which really doesn't work with the "run the file" idea.

Chapter 8 is a little different just because those "create table" statements are so large that they're kind of annoying to copy & paste, or to select+execute in pgAdmin. Specifically for chapter 8, it might do to have a separate file for create table just so that the reader can simply execute those, and all the other statements in another file.

anthonydb commented 7 years ago

OK, that sounds like a good idea. I'll switch that up when I revise the chapter based on your additional comments. Thanks!