class Order_Content(db.Model): __tablename__ = 'OrderContent' order_number = db.Column(db.Integer, db.ForeignKey('Order.order_number'), primary_key=True) product_number = db.Column(db.Integer, db.ForeignKey('Product.product_number'), primary_key=True) def __init__(self,order_number,product_number): self.order_number = order_number self.product_number = product_number
class Placed_Order(db.Model): __tablename__ = 'PlacedOrder' username = db.Column(db.String(40), db.ForeignKey('Buyer.username'), primary_key=True) order_number = db.Column(db.Integer, db.ForeignKey('Order.order_number'), primary_key=True) def __init__(self, username, order_number): self.username = username self.order_number = order_number
class Messages(db.Model): __tablename__ = 'Messages' uname1 = db.Column(db.String(40), db.ForeignKey('User.username'), primary_key=True) uname2 = db.Column(db.String(40), db.ForeignKey('User.username'), primary_key=True) message = db.Column(db.String(120), primary_key=True) def __init__(self, uname1, uname2, message): self.uname1 = uname1 self.uname2 = uname2 self.message = message
class Delivery(db.Model): __tablename__ = 'Delivery' order_number = db.Column(db.Integer, db.ForeignKey('Order.order_number'), primary_key=True) id = db.Column(db.Integer, db.ForeignKey('DeliveryPerson.id'), primary_key=True) username = db.Column(db.String(40), db.ForeignKey('Buyer.username')) date = db.Column(db.Date, default=datetime.now().date()) def __init__(self,order_number,id, username, date): self.order_number = order_number self.id = id self.username = username self.date = date
class Seller(db.Model): __tablename__ = 'Seller' sellerID = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(40), db.ForeignKey('User.username')) mode = db.Column(db.String(6)) rating = db.Column(db.Float) def __init__ (self, username, mode, rating): self.username = username self.mode = mode self.rating = rating
class Product(db.Model): __tablename__ = 'Product' product_number = db.Column(db.Integer, primary_key=True) sellerID = db.Column(db.Integer, db.ForeignKey('Seller.sellerID')) name = db.Column(db.String(40)) price = db.Column(db.Float) quantity = db.Column(db.Integer) description = db.Column(db.String(120)) def __init__(self, sellerID, name, price, quantity, description): self.sellerID = sellerID self.name = name self.price = price self.quantity = quantity self.description = description
class Buyer(db.Model): __tablename__ = 'Buyer' username = db.Column(db.String(40), db.ForeignKey('User.username'), primary_key=True) city = db.Column(db.String(40)) zip_code = db.Column(db.Integer) street = db.Column(db.String(40)) telephone_number = db.Column(db.String(25)) def __init__(self, username, city, zip_code, street, telephone_number): self.username = username self.city = city self.zip_code = zip_code self.street = street self.telephone_number = telephone_number