Tutorial: Student Database¶
In this beginner-friendly tutorial, you will create a student records database, insert student profiles, filter and sort query results, perform updates, and delete records.
1. Create the Table¶
Launch memora and create a students table:
CREATE TABLE students (
student_id INT PRIMARY KEY,
name STRING(50),
major STRING(40),
gpa FLOAT,
is_active BOOL
);
Output:
Verify the schema:
2. Insert Records¶
Insert four students into the table using positional column order:
INSERT INTO students VALUES (101, "Alice Chen", "Computer Science", 3.85, true);
INSERT INTO students VALUES (102, "Bob Martin", "Mechanical Engineering", 3.40, true);
INSERT INTO students VALUES (103, "Clara Gomez", "Computer Science", 3.92, true);
INSERT INTO students VALUES (104, "David Lee", "Mathematics", 2.95, false);
3. Query All Students¶
Retrieve the entire table:
Project only the student names and GPAs:
4. Filter with WHERE¶
Find all Computer Science majors:
Find students on the Dean's List (GPA >= 3.8):
5. Sort with ORDER BY and LIMIT¶
Rank the top 2 active students by GPA:
Output:
6. Update a Record¶
Suppose Bob Martin improves his GPA to 3.65:
Output:
Verify that the updated GPA is reflected:
7. Delete a Record¶
Delete the inactive student record:
Output:
Verify that David Lee no longer appears in the active student list:
8. Historical Verification¶
Even though David Lee was deleted, his history is safely preserved in MemoraDB's append-only storage! You can inspect his past record at any time: