-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathORM
50 lines (40 loc) · 1.71 KB
/
ORM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Part 2: ORM Exercises (Object Relational Mapping)
1. Implement a Library System with ORM
• Use an ORM tool (like Django ORM, SQLAlchemy, or Hibernate) to implement the Library Management System from the OOD exercise.
• Create database tables for Book, Member, Librarian, and Loan.
• Add functionality:
• Query the database for books on loan.
• Update the database when a book is returned.
2. Build a Blogging Platform
• Implement models for User, Post, and Comment using an ORM.
• Add relationships:
• A Post belongs to a User.
• A Comment belongs to both a Post and a User.
• Perform queries:
• Fetch all posts by a specific user.
• Retrieve comments for a particular post.
3. Develop an E-commerce Platform
• Create models for User, Product, Cart, and Order.
• Add relationships:
• A User has a Cart.
• A Cart contains multiple Products.
• An Order is linked to a User and a Cart.
• Practice queries:
• Fetch the cart items for a user.
• Retrieve the total price of an order.
4. Build a To-Do Application
• Use an ORM to model a Task table.
• Include attributes like id, title, description, due_date, and status.
• Add features:
• Create, read, update, and delete tasks (CRUD operations).
• Query tasks by status or due date.
5. Create a Forum System
• Implement models for User, Thread, Post, and Category.
• Add relationships:
• A Thread belongs to a Category.
• A Post belongs to a Thread.
• A Post is authored by a User.
• Practice with queries:
• Fetch all threads in a category.
• Retrieve all posts in a thread.
• Get all threads started by a specific user.