This project is a simple database system built using Python and SQLAlchemy ORM. It models a shop where users can place orders for products.
- Python
- SQLAlchemy (ORM)
- SQLite
- id (Primary Key)
- name
- email (unique)
- id (Primary Key)
- name
- price
- id (Primary Key)
- user_id (Foreign Key → User)
- product_id (Foreign Key → Product)
- quantity
- status (Boolean → shipped or not)
- One User → Many Orders
- One Product → Many Orders
- Each Order belongs to one User and one Product
- Create database using SQLite
- Define tables using SQLAlchemy ORM
- Insert sample data (User, Product, Order)
- Query all not shipped orders
- Count total number of orders per user
- Install dependencies:
pip install sqlalchemy
- Run the script:
python RelationalDB-Python.py
- The database file
shop.dbwill be created automatically.
--- Not Shipped Orders ---
Order 1 is NOT shipped
--- Orders Per User ---
Yousef has 2 orders
- Explain the purpose of the system
- Describe the database tables and relationships
- Show how data is inserted
- Demonstrate queries and results