CREATE TABLE "answers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "answer" varchar(255), "question_id" integer, "created_at" datetime, "updated_at" datetime); CREATE TABLE "questions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "url" varchar(255), "question" varchar(255), "user_id" integer, "created_at" datetime, "updated_at" datetime); CREATE TABLE "results" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "question_id" integer, "answer_id" integer, "created_at" datetime, "updated_at" datetime); CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL); CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(255), "crypted_password" varchar(255), "password_salt" varchar(255), "persistence_token" varchar(255), "created_at" datetime, "updated_at" datetime); CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
- Save this as file named whatsayye-schema.sql
- Create the database: sqlite3 whatsayye.sqlite3 < whatsayye-schema.sql
- Use sqlite3 or sqlitebrowser to add / edit data
Notice: This has an extra relationship in it (one result belongs to one question) that we found out in a later lab that we don't need.
No comments:
Post a Comment