reactnative_mobilemk/dbstructure.md

3.9 KiB
Raw Permalink Blame History

DB

Collections and Fields

  1. Users

    ID (default, auto-generated) Name (string) - Full name of the user. Email (email) - User's email address. Phone (string) - Contact number. ProfileImage (file) - Profile picture of the user. Location (geo-point) - Geographical location (latitude and longitude). CreatedAt (timestamp) - When the user registered.

  2. Cars

    ID (default, auto-generated) Title (string) - Title or headline for the car listing. Description (text) - Detailed description of the car. Price (number) - Price of the car. Make (string) - Car manufacturer (e.g., Toyota, Ford). Model (string) - Specific model of the car. Year (number) - Year of manufacture. Mileage (number) - Total kilometers or miles driven. FuelType (enum) - Type of fuel (e.g., Petrol, Diesel, Electric). Transmission (enum) - Transmission type (e.g., Manual, Automatic). Condition (enum) - Condition of the car (e.g., New, Used). Images (file array) - Images of the car. Location (geo-point) - Where the car is located. PostedBy (relationship) - Reference to the User who posted the car. CreatedAt (timestamp) - When the listing was created.

  3. Favorites

    ID (default, auto-generated) UserID (relationship) - Reference to the User who favorited the car. CarID (relationship) - Reference to the Car being favorited. CreatedAt (timestamp) - When the favorite was added.

  4. Messages

    ID (default, auto-generated) SenderID (relationship) - Reference to the User sending the message. ReceiverID (relationship) - Reference to the User receiving the message. CarID (relationship) - Reference to the Car related to the conversation. Message (text) - Message content. CreatedAt (timestamp) - When the message was sent.

  5. Reviews

    ID (default, auto-generated) UserID (relationship) - Reference to the User being reviewed. ReviewerID (relationship) - Reference to the User leaving the review. Rating (number) - Rating score (e.g., 15). Comment (text) - Review content. CreatedAt (timestamp) - When the review was created.

Relationships

Users ↔ Cars: One-to-Many (A User can post multiple Cars).
Users ↔ Favorites: One-to-Many (A User can have multiple favorite Cars).
Users ↔ Messages: One-to-Many (A User can send and receive multiple Messages).
Users ↔ Reviews: One-to-Many (A User can give and receive Reviews).

Indexes

Cars Collection
    Index on Location for geo-based searches.
    Index on Price for filtering by price range.
    Index on Make and Model for specific searches.
Messages Collection
    Composite index on SenderID and ReceiverID for efficient message retrieval.

CommercialSlots

ID (default, auto-generated)
UserID (relationship) - Reference to the User who purchased the slot.
CarID (relationship) - Reference to the Car being featured.
SlotType (enum) - Type of slot (e.g., Featured, Regular).
StartDate (timestamp) - When the slot starts.
EndDate (timestamp) - When the slot ends.
Price (number) - Price paid for the slot.
PaymentStatus (enum) - Payment status (Pending, Completed, Failed).
CreatedAt (timestamp) - When the slot was purchased.

Updated Relationships

Users ↔ CommercialSlots: One-to-Many (A User can buy multiple commercial slots).
Cars ↔ CommercialSlots: One-to-Many (A Car can appear in multiple commercial slots of different types).

Additional Notes

SlotType: You can use an enum to differentiate between Featured and Regular.
Payment Tracking: If you plan to integrate payment gateways, consider adding a Transactions collection to track payments comprehensively.
Slot Duration Logic: Ensure validations in your backend (or Appwrite Functions) to enforce slot duration limits and prevent overlapping slots for the same car.

Would you like me to expand on payment tracking or slot scheduling logic?