Those relationships are simply foreign key -> primary key mappings. You can generate those yourself in a script. You can even do it randomly if you want (a row's FK = random number from 1 to size of other table's dataset).
What is your opinion on the nostarch manga guides?
People who can generate databases by various methods most likely don't need a SQL tutorial in the first place. What you're saying is similar to a C tutorial that starts off with running a "hello world" program binary through a debugger even though you don't have a binary one and were told nothing about how to write one.
I have the suspicion that most computer science people are highly-functioning autists. There has to be an explanation why the fuck it is so hard to find a computer scientist (or someone working in that field) who can actually explain stuff. Starting an SQL tutorial with SELECT is just as said. I know SELECT is among the more frequently used commands, but it is not the first query in the life of a database.
I learned with the Oreilly MSQL/MySQL book they published in the late 90's. They didn't give me any data set. Reading the chapters on theory plus the stupid examples (make a CD collection database or whatever) was enough to understand how it all fit together. It's not nearly as complicated as writing a C compiler or reverse-engineering a binary. I think that if the book can't explain basic SQL well enough that the reader can make his own tables to play with, then it's just not a good book.
I luv u
The point is that the book progresses from conceptually constructing a would-be-database (with the tables being on paper, in a text editor, a spreadsheet etc.) straight to doing SQL queries such as SELECT on an actual database which the reader obviously doesn't have by that point. They should have either structured the book so that the reader could construct the database first by following the tutorial and only then try to retrieve data from it, or the publisher could have provided a sample database in a handful popular free formats (such as MySQL or SQLite) as a download. As it is, the reader either has to skip ahead on their own to somehow construct an actual database if they want to play around with the SQL examples the book gives, or just keep nodding their head and wait until later.
Is it safe to say that a table basically is a struct holding an array of n (number of columns) pointers to char (the header with the column names) and an array of m (number of records in the table) structs holding n members of whatever types the data in the given columns are?
typedef struct { unsigned int id; char *name; int value;} record;typedef struct { char *header[] = {"id", "name", "value"}; record data[] = {{1001, "fizz", 3}, {1002, "buzz", 5}, {1003, "fizzbuzz", 15}};} table;
Why would that be stupid? Technically it's a suitable subject for a database, and everyone had a collection of CDs back then so it would be engaging to make a database of their own collection.
マンガでわかる電子回路 田中 賢一
It was released in moon as were the rest. Good to know.
Oh crap. Apparently subconciously tried to do two things at once and tried to define struct member values in a typedef (which makes no sense whatsoever). Corrected below in a complete program that creates and then outputs a table.
#include #define COLS 3#define ROWS 3#define COLWIDTH "10"int main(void){ typedef struct { unsigned int id; char *name; int value; } record_t; typedef struct { char *header[COLS]; record_t data[ROWS]; } table_t; table_t foo = { {"id", "name", "value"}, { {1001, "fizz", 3}, {1002, "buzz", 5}, {1003, "fizzbuzz", 15} } }; int i; /* output table header */ for (i = 0; i < COLS; ++i) { printf("%" COLWIDTH "s", foo.header[i]); } printf("\n"); /* output table data */ for (i = 0; i < ROWS; ++i) { printf("%" COLWIDTH "u", foo.data[i].id); printf("%" COLWIDTH "s", foo.data[i].name); printf("%" COLWIDTH "d\n", foo.data[i].value); } return 0;}