Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

City model - Making a unique record based on city name, state, and country (3 fields combined) #10

Open
itsahsiao opened this issue May 11, 2016 · 0 comments

Comments

@itsahsiao
Copy link
Owner

itsahsiao commented May 11, 2016

Re: Issue #3 for data modeling, City model right now is simple:

class City(db.Model):
    """City where the restaurant is in."""

    __tablename__ = "cities"

    city_id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    city_name = db.Column(db.String(100), nullable=False)
    updated_At = db.Column(db.DateTime, default=datetime.datetime.utcnow)

However, there could be two cities with the same name, but in different states or countries.
Per mentor, need to make it unique across 3 fields (city, state, country), so that there will not be a duplicated record in the table.

Something to look into: http://stackoverflow.com/questions/10059345/sqlalchemy-unique-across-multiple-columns

@itsahsiao itsahsiao changed the title City model - Additional fields so that 3 fields together make it unique City model - Making a unique record based on city name, state, and country May 11, 2016
@itsahsiao itsahsiao changed the title City model - Making a unique record based on city name, state, and country City model - Making a unique record based on city name, state, and country (3 fields combined) May 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant