UCS310 โ€” DBMS Project ยท 2025โ€“26

Lost & Found
Portal

A centralized, database-driven system to manage and track lost and found items across Thapar Institute of Engineering & Technology.

5
Tables
3NF
Normalised
2
Triggers
3
Stored Procs

What the portal does

A full backend-focused solution with SQL, PL/SQL triggers, and a live Flask web interface.

๐Ÿ”

User Authentication

Secure registration and login with SHA-256 password hashing. Role-based access for users and admins.

๐Ÿ“‹

Report Lost Items

Students report lost items with name, category, date, and location. Records are instantly stored in the database.

โœ…

Report Found Items

Found items are logged by any user. The system checks for potential matches by category automatically.

๐Ÿ”—

Claim Matching

Users submit claims linking a lost item to a found item. An API endpoint suggests matches from the same category.

โšก

SQL Triggers

Two database triggers auto-update item statuses when claims are created or approved โ€” no manual updates needed.

๐Ÿ›ก๏ธ

Admin Panel

Admins approve or reject claims, view all users, and see item statistics broken down by category.

๐Ÿ”

Search & Filter

Full-text search across item names, descriptions, and locations. Filter by any of the 8 categories.

๐Ÿ“Š

Datasette Viewer

Raw SQLite database browsable via Datasette with saved SQL queries for reports and analytics.

Relational Schema

Normalised to 3NF/BCNF โ€” no partial or transitive dependencies.

USER

PKUser_IDINTEGER
NameTEXT
EmailTEXT UNIQUE
PhoneTEXT
PasswordTEXT
Roleuser|admin

CATEGORY

PKCategory_IDINTEGER
Category_NameTEXT

LOST_ITEM

PKLost_IDINTEGER
Item_NameTEXT
DescriptionTEXT
Date_LostTEXT
LocationTEXT
StatusLost|Matched|Returned
FKUser_IDโ†’ USER
FKCategory_IDโ†’ CATEGORY

FOUND_ITEM

PKFound_IDINTEGER
Item_NameTEXT
DescriptionTEXT
Date_FoundTEXT
LocationTEXT
StatusUnclaimed|Claimed|Returned
FKUser_IDโ†’ USER
FKCategory_IDโ†’ CATEGORY

CLAIM

PKClaim_IDINTEGER
FKLost_IDโ†’ LOST_ITEM
FKFound_IDโ†’ FOUND_ITEM
StatusPending|Approved|Rejected
Claimed_OnTEXT

SQL & PL/SQL

Key queries, triggers, and stored procedures powering the portal.

-- Create normalised tables with constraints
CREATE TABLE LOST_ITEM (
    Lost_ID     INTEGER PRIMARY KEY AUTOINCREMENT,
    Item_Name   TEXT NOT NULL,
    Description TEXT,
    Date_Lost   TEXT NOT NULL,
    Location    TEXT,
    Status      TEXT NOT NULL DEFAULT 'Lost'
                CHECK(Status IN ('Lost','Matched','Returned')),
    User_ID     INTEGER NOT NULL,
    Category_ID INTEGER,
    FOREIGN KEY (User_ID)     REFERENCES USER(User_ID),
    FOREIGN KEY (Category_ID) REFERENCES CATEGORY(Category_ID)
);
-- Trigger 1: Mark items Matched/Claimed when a claim is submitted
CREATE TRIGGER trg_claim_pending
AFTER INSERT ON CLAIM
BEGIN
    UPDATE LOST_ITEM  SET Status = 'Matched'
        WHERE Lost_ID  = NEW.Lost_ID;
    UPDATE FOUND_ITEM SET Status = 'Claimed'
        WHERE Found_ID = NEW.Found_ID;
END;

-- Trigger 2: Mark both items Returned when claim is Approved
CREATE TRIGGER trg_claim_approved
AFTER UPDATE OF Status ON CLAIM
WHEN NEW.Status = 'Approved'
BEGIN
    UPDATE LOST_ITEM  SET Status = 'Returned'
        WHERE Lost_ID  = NEW.Lost_ID;
    UPDATE FOUND_ITEM SET Status = 'Returned'
        WHERE Found_ID = NEW.Found_ID;
END;
-- Find potential matches for a lost item (same category)
SELECT
    f.Found_ID,
    f.Item_Name,
    f.Description,
    f.Date_Found,
    f.Location,
    c.Category_Name,
    u.Name AS Found_By
FROM FOUND_ITEM f
LEFT JOIN CATEGORY c ON f.Category_ID = c.Category_ID
JOIN      USER u      ON f.User_ID     = u.User_ID
WHERE
    f.Category_ID = (
        SELECT Category_ID FROM LOST_ITEM
        WHERE Lost_ID = :lost_id
    )
    AND f.Status = 'Unclaimed'
ORDER BY f.Date_Found DESC;
-- Stored procedure: Add a new lost item (PL/SQL style)
CREATE PROCEDURE Add_Lost_Item (
    p_item_name   TEXT,
    p_description TEXT,
    p_date_lost   TEXT,
    p_location    TEXT,
    p_user_id     INTEGER,
    p_category_id INTEGER
)
BEGIN
    -- Validate user exists
    IF NOT EXISTS (
        SELECT 1 FROM USER WHERE User_ID = p_user_id
    ) THEN
        SIGNAL SQLSTATE '45000'
            SET MESSAGE_TEXT = 'Invalid user ID';
    END IF;

    INSERT INTO LOST_ITEM
        (Item_Name, Description, Date_Lost, Location, User_ID, Category_ID)
    VALUES
        (p_item_name, p_description, p_date_lost, p_location,
         p_user_id, p_category_id);
END;

Tech Stack

Backend-focused with a clean web interface for demonstration.

๐Ÿ—„๏ธ

SQLite

Lightweight relational DB with full SQL support & triggers

๐Ÿ

Python / Flask

Web framework serving the portal frontend & REST API

๐Ÿ“Š

Datasette

Browse raw DB tables, run saved SQL queries

๐ŸŽจ

HTML / CSS / JS

Custom responsive frontend โ€” no frameworks needed

๐Ÿ”’

SHA-256 Auth

Password hashing with session-based authentication

โšก

SQL Triggers

Automatic status updates on claim events

Group Members

B.Tech 2nd Year โ€” Thapar Institute of Engineering & Technology

๐Ÿง‘โ€๐Ÿ’ป

Bhavin Bhatti

1024030811
๐Ÿ‘ฉโ€๐Ÿ’ป

Bhoomi Mittal

1024030814
๐Ÿง‘โ€๐Ÿ’ป

Aatish Kumar Sahu

10240307