Tuesday, April 15, 2025

MAD1 -DB-1

 List of Questions 

Questions Related to Data Base

1.Explain your models?

It is related to your models.py file but common model is user for example :

1. User Model

Represents all users in the system  including Admins, Sponsors, and Influencers.

Fields:

  • id: Unique identifier

  • username: Login name

  • email: User email

  • password_hash: Securely stored password (hashed)

  • role: User type (admin/sponsor/influencer)

  • created_at: Timestamp of account creation

Passwords are stored using secure hashing (e.g., Werkzeug or bcrypt) to prevent exposure in case of a database breach.


2. Campaign Model

Represents sponsorship campaigns created by sponsors.

Fields:

  • id: Unique identifier

  • title: Name of the campaign

  • description: Campaign details

  • category: Niche/category (e.g., tech, fashion)

  • budget: Amount sponsor is willing to pay

  • status: Status (public/private/flagged)

  • sponsor_id: Foreign key linking to User

  • created_at: Date created

Only sponsors can create/update/delete campaigns. Admins can moderate them.


3. AdRequest Model

Connects influencers with campaigns by allowing them to send requests.

Fields:

  • id: Unique identifier

  • influencer_id: Foreign key linking to User

  • campaign_id: Foreign key linking to Campaign

  • status: pending/approved/rejected

  • message: Optional pitch from influencer

  • submitted_at: Date of request

Influencers use this model to apply for campaigns.


4. Rating/Review Model (Optional)

Allows sponsors to rate influencers after a campaign ends.

Fields:

  • id: Unique identifier

  • sponsor_id: Foreign key to User

  • influencer_id: Foreign key to User

  • campaign_id: Foreign key to Campaign

  • rating: Score (e.g., 1 to 5)

  • review: Text review

  • created_at: Date of review

2.what if hacker hacks your database? Implement password security feature?
(or)
2.What if a hacker gains access to your database?
To secure user passwords, it's important to implement a password security feature. One common approach is to use hashing to store passwords. Hashing is a one-way function, meaning it cannot be reversed. Even if an attacker gets access to the database, they won't be able to retrieve the original passwords because the hashed values do not reveal the actual password. This adds a strong layer of protection against unauthorized access.
3.what is werkzeug security?

Werkzeug security is a built-in part of the Flask ecosystem that helps you safely store and check passwords.

You should never store plain passwords in a database. Instead, you hash them which turns the password into a scrambled, unreadable string.

Werkzeug helps you do this easily using two main functions:

1. generate_password_hash(password)

  • Takes a plain password (like "mypassword")

  • Returns a hashed version of it

  • This hash is what you store in the database

 2. check_password_hash(hashed_password, password)

  • Compares a plain password with the hashed one

  • Returns True if they match

For this you have to import 
from werkzeug.security import generate_password_hash, check_password_hash

hashed_password = generate_password_hash("mypassword")
check_password_hash(hashed_password, "mypassword")

























No comments:

Post a Comment

Mangerial Economics Quiz1 solutions Guide

Mangerial Economics Quiz1 solutions Guide  solutions watch on you tube channel