class Guest(db.Model): guest_id = db.Column(db.Integer, db.Sequence('guest_id'), primary_key=True) guest_fname = db.Column(db.String(100), nullable=False) guest_lname = db.Column(db.String(100), nullable=False) guest_email = db.Column(db.String(100)) reservations = db.relationship('Reservation', backref='guest') credit_cards = db.relationship('CreditCard', backref='guest')
class GolfCourse(db.Model): golf_course_id = db.Column(db.Integer, db.Sequence('golf_course_id'), primary_key=True) golf_course_name = db.Column(db.String(100)) golf_course_holes = db.Column(db.Integer) resort_id = db.Column(db.Integer, db.ForeignKey('resort.resort_id'))
class Building(db.Model): building_id = db.Column(db.Integer, db.Sequence('building_id'), primary_key=True) building_name = db.Column(db.String(100), nullable=False) building_address = db.Column(db.String, nullable=False) resort_id = db.Column(db.Integer, db.ForeignKey('resort.resort_id')) rooms = db.relationship('Room', backref='building')
class Resort(db.Model): resort_id = db.Column(db.Integer, db.Sequence('resort_id'), primary_key=True) resort_name = db.Column(db.String(100), nullable=False) buildings = db.relationship('Building', backref='resort') skipasses = db.relationship('SkiPass', backref='resort') rentals = db.relationship('Rental', backref='resort') golf_courses = db.relationship('GolfCourse', backref='resort')
class CreditCard(db.Model): cc_id = db.Column(db.Integer, db.Sequence('cc_id'), primary_key=True) cc_number = db.Column(db.String(16), nullable=False) cc_provider = db.Column(Enum('Visa', 'MasterCard', 'AmericanExpress', name='accepted_cc_providers'), default='Visa') cc_address = db.Column(db.String, nullable=False) cc_expiration = db.Column(db.Date, default=date.today) guest_id = db.Column(db.Integer, db.ForeignKey('guest.guest_id')) reservations = db.relationship('Reservation', backref='credit_card')