class Location(db.Model): __tablename__ = 'locations' id = db.Column(db.Integer, primary_key=True) # name = db.Column(id.Text) zip = db.Column(db.String) # borough = db.Column(db.Text) complaints = db.relationship('Complaint', back_populates='location') # name = db.Column(db.Text) borough_id = db.Column(db.Integer, db.ForeignKey('boroughs.id')) borough = db.relationship("Borough", back_populates='locations')
class Complaint(db.Model): __tablename__ = 'complaints' id = db.Column(db.Integer, primary_key=True) type = db.Column(db.Text) status = db.Column(db.Text) method = db.Column(db.Text) date = db.Column(db.Text) # date_id =db.Column(db.Integer, db.ForeignKey('dates.id')) agency_name = db.Column(db.Text, db.ForeignKey('agencies.name')) agency = db.relationship('Agency', back_populates='complaints') location = db.relationship('Location', back_populates='complaints') location_id = db.Column(db.Integer, db.ForeignKey('locations.id')) # location_name = db.Column(db.Text, db.ForeignKey('locations.name')) #city = db.relationship('City',back_populates='complaints') #city_name = db.Column(db.Text,db.ForeignKey('cities.name')) borough_name = db.Column(db.Integer, db.ForeignKey('boroughs.name')) borough = db.relationship('Borough', back_populates='complaints')
class Borough(db.Model): __tablename__ = 'boroughs' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text) locations = db.relationship('Location', back_populates='borough') complaints = db.relationship('Complaint', back_populates='borough')
class Agency(db.Model): __tablename__ = 'agencies' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text) complaints = db.relationship('Complaint', back_populates='agency')