Database schemas and foreign keys are really beyond the scope of this discussion board. I'd suggest going through some tutorials, "learn sql the hard way" is a good one.
Peewee foreign keys, however, I'm happy to explain. In a sense they are syntactic sugar. So from a database schema point of view, I might have the user table like:
id | integer not null primary key
username | varchar(64)
And the tweet table like:
id | integer not null primary key
user_id | integer not null references user(id)
content | text
The "tweet.user_id" column is the foreign key (hence the 'references' constraint). The "
user.id" is the column the foreign key refers to.
When using peewee, you would write "user = ForeignKeyField(User, db_column='user_id', to_field='id')". By default peewee will assume foreign keys point to the primary key of the related model, so you can leave off the "to_field" parameter. Furthermore, peewee uses a convention for the column name on foreign keys, which is "field_name + _id". So you can also leave off the "db_column='user_id'" in the above example.
Hope that helps clarify.