RelationalDesign: OPLMS--DML.sql

File OPLMS--DML.sql, 3.8 KB (added by 221296, 8 months ago)
Line 
1INSERT INTO user_entity (id, first_name, last_name, email, password, role) VALUES
2(1, 'Ana', 'Adminova', 'ana.admin@oplms.com', 'pass123', 'ADMIN'),
3(2, 'Ivan', 'Instruktorov', 'ivan.instructor@oplms.com', 'pass123', 'INSTRUCTOR'),
4(3, 'Elena', 'Instruktorka', 'elena.instructor@oplms.com','pass123', 'INSTRUCTOR'),
5(4, 'Marko', 'Userov', 'marko.user@oplms.com', 'pass123', 'USER'),
6(5, 'Sara', 'Userova', 'sara.user@oplms.com', 'pass123', 'USER'),
7(6, 'Dalia', 'Userova', 'dalia.user@oplms.com', 'pass123', 'USER');
8
9INSERT INTO administrators (id) VALUES (1);
10
11INSERT INTO instructors (id) VALUES
12(2),
13(3);
14
15INSERT INTO users (id) VALUES
16(4),
17(5),
18(6);
19
20INSERT INTO subscription_plan (plan_id, name, price, duration_months, description, access_type) VALUES
21(1, 'Basic', 9.99, 1, 'Access to basic courses', 'BASIC'),
22(2, 'Pro', 19.99, 1, 'Access to all courses', 'FULL'),
23(3, 'Annual Pro', 199.99, 12, 'Full access for 12 months', 'FULL');
24
25INSERT INTO user_subscription (subscription_id, user_id, plan_id, start_date, end_date, status) VALUES
26(1, 4, 2, DATE '2025-12-01', DATE '2025-12-31', 'ACTIVE'),
27(2, 5, 1, DATE '2025-12-05', DATE '2026-01-05', 'ACTIVE');
28
29INSERT INTO payment (payment_id, user_id, subscription_id, amount) VALUES
30(1, 4, 1, 19.99),
31(2, 5, 2, 9.99);
32
33
34INSERT INTO support_ticket (ticket_id, user_id, admin_id, subject, description, status) VALUES
35(1, 4, 1, 'Payment issue', 'My payment shows pending.', 'OPEN'),
36(2, 5, 1, 'Course access', 'I cannot access one course.', 'IN_PROGRESS');
37
38
39INSERT INTO category (category_id, name, description) VALUES
40(1, 'Programming', 'Programming related courses'),
41(2, 'Databases', 'SQL, relational design and normalization'),
42(3, 'Networks', 'Networking fundamentals and security');
43
44
45INSERT INTO course (course_id, name, price, status, instructor_id) VALUES
46(1, 'SQL Fundamentals',0.00, 'ACTIVE', 2),
47(2, 'Database Design (ER -> Relational)',29.99,'ACTIVE', 2),
48(3, 'Network Security Basics',19.99, 'ACTIVE', 3);
49
50
51INSERT INTO course_category (course_id, category_id) VALUES
52(1, 2),
53(2, 2),
54(3, 3);
55
56
57INSERT INTO module (module_id, course_id, title, description) VALUES
58(1, 1, 'Intro to SQL', 'Basics of SELECT, WHERE, ORDER BY'),
59(2, 1, 'Joins', 'INNER/LEFT JOIN and practice'),
60(3, 2, 'ER Modeling', 'Entities, relationships, cardinalities'),
61(4, 2, 'Relational Mapping', 'Transform ER to tables, PK/FK'),
62(5, 3, 'Security Concepts', 'CIA, threats, authentication');
63
64
65INSERT INTO lesson (lesson_id, module_id, title, material) VALUES
66(1, 1, 'SQL SELECT basics', 'Intro material for SELECT'),
67(2, 2, 'JOIN examples', 'Practice joins with examples'),
68(3, 3, 'ER entities and attributes','How to identify entities'),
69(4, 4, 'Mapping rules', 'Rules for PK/FK and relations'),
70(5, 5, 'Security overview', 'Basic security principles');
71
72
73INSERT INTO quiz (quiz_id, total_points, passing_score, lesson_id) VALUES
74(1, 100, 60, 1),
75(2, 50, 30, 3),
76(3, 80, 50, 5);
77
78
79INSERT INTO enrollment (enrollment_id, user_id, course_id, enroll_date, completion_status, progress_percentage) VALUES
80(1, 4, 2, DATE '2025-12-10', 'IN_PROGRESS', 70),
81(2, 5, 1, DATE '2025-12-12', 'IN_PROGRESS', 40);
82
83
84INSERT INTO quiz_attempt (attempt_id, score, attempt_date, user_id, quiz_id) VALUES
85(1, 40, DATE '2025-12-15', 4, 2),
86(2, 45, DATE '2025-12-16', 5, 1);
87
88
89UPDATE enrollment
90SET completion_status = 'COMPLETED',
91 progress_percentage = 100
92WHERE enrollment_id = 1;
93
94UPDATE enrollment
95SET completion_status = 'IN_PROGRESS',
96 progress_percentage = 40
97WHERE enrollment_id = 2;
98
99
100INSERT INTO certificate (certificate_id, enrollment_id, issue_date, certificate_code, status) VALUES
101(1, 1, DATE '2025-12-20', 'CERT-DB-2025-0001', 'ISSUED');