58 lines
2 KiB
SQL
58 lines
2 KiB
SQL
CREATE TABLE `courses` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`title` text NOT NULL,
|
|
`subject` text NOT NULL,
|
|
`status` text DEFAULT 'processing' NOT NULL,
|
|
`created_at` text DEFAULT (datetime('now')) NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `lessons` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`topic_id` text NOT NULL,
|
|
`content` text NOT NULL,
|
|
`created_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
FOREIGN KEY (`topic_id`) REFERENCES `topics`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `quiz_questions` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`topic_id` text NOT NULL,
|
|
`question` text NOT NULL,
|
|
`type` text NOT NULL,
|
|
`options` text,
|
|
`answer` text NOT NULL,
|
|
`explanation` text NOT NULL,
|
|
FOREIGN KEY (`topic_id`) REFERENCES `topics`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `topics` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`course_id` text NOT NULL,
|
|
`title` text NOT NULL,
|
|
`description` text NOT NULL,
|
|
`order` integer NOT NULL,
|
|
`prerequisite_topic_ids` text DEFAULT '[]' NOT NULL,
|
|
`difficulty` integer DEFAULT 1 NOT NULL,
|
|
FOREIGN KEY (`course_id`) REFERENCES `courses`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `uploads` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`course_id` text NOT NULL,
|
|
`filename` text NOT NULL,
|
|
`type` text NOT NULL,
|
|
`stored_path` text NOT NULL,
|
|
`created_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
FOREIGN KEY (`course_id`) REFERENCES `courses`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `user_progress` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`course_id` text NOT NULL,
|
|
`topic_id` text NOT NULL,
|
|
`lesson_complete` integer DEFAULT false NOT NULL,
|
|
`quiz_score` integer,
|
|
`updated_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
FOREIGN KEY (`course_id`) REFERENCES `courses`(`id`) ON UPDATE no action ON DELETE no action,
|
|
FOREIGN KEY (`topic_id`) REFERENCES `topics`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|