Created
July 9, 2013 18:12
-
-
Save mjhea0/5959729 to your computer and use it in GitHub Desktop.
This file contains 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
#----SCHEMA----# | |
sqlite> .schema myapp_course | |
CREATE TABLE "myapp_course" ( | |
"id" integer NOT NULL PRIMARY KEY, | |
"name" varchar(30) NOT NULL | |
); | |
sqlite> .schema myapp_student | |
CREATE TABLE "myapp_student" ( | |
"id" integer NOT NULL PRIMARY KEY, | |
"name" varchar(30) NOT NULL | |
); | |
sqlite> .schema myapp_student_courses | |
CREATE TABLE "myapp_student_courses" ( | |
"id" integer NOT NULL PRIMARY KEY, | |
"student_id" integer NOT NULL, | |
"course_id" integer NOT NULL, | |
UNIQUE ("student_id", "course_id") | |
); | |
CREATE INDEX "myapp_student_courses_6234103b" ON "myapp_student_courses" ("course_id"); | |
CREATE INDEX "myapp_student_courses_94741166" ON "myapp_student_courses" ("student_id"); | |
#----DATA----# | |
sqlite> select * from myapp_course; | |
1|Math | |
2|Science | |
3|English | |
sqlite> select * from myapp_student; | |
1|John | |
2|Carl | |
sqlite> select * from myapp_student_courses; | |
1|1|1 | |
2|1|2 | |
3|2|3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment