Given this simple table, written in SQLAlchemy and Django models.py, how would you establish that the UPC will be unique, if not null. UPC will not be available for all elements, but if it should be unique.
class Products(base): __tablename__ = u'products' id = Column(Integer(), primary_key=True, autoincrement = True) product_name = Column(String(), unique=True, nullable=False) upc = Column(String(), nullable = True)
and
class Products(models.Model): id = models.AutoField(primary_key=True) product_name = models.TextField() upc = models.TextField(null=True, blank=True)
Mch
source share