I'm working on simple asset manager database using peewee. Each asset can belong to one of the types: image or video.
Let's say it looks like this:
# MAIN ASSET
class Asset(Model):
name = CharField()
datetime = DateTimeField()
miniature = CharField()
preview = CharField()
type_ = ForeignKeyField()
class Meta:
database = DB
# TYPE SPECIFIC
class Image(Model):
resolution_x = IntegerField()
resolution_y = IntegerField()
channels = CharField()
layers = IntegerField()
class Meta:
database = DB
class Video(Model):
resolution_x = IntegerField()
resolution_y = IntegerField()
framerate = FloatField()
bitrate = FloatField()
duration = FloatField()
class Meta:
database = DB
I would like to keep all the assets in one table, asset specific fields in other and connect them with "type_" field (ex. using foreign key or something). How can I achieve that? I suppose foreign key is a bad approach since it requires a predetermined model.