S
Size: a a a
S
G
ЮЧ
ЮЧ
G
S
ЮЧ
class User(Model):
user_id
=
fields.BigIntField
(pk
=True, generated=False)
first_name
=
fields.CharField
(max_length
=255)
last_name
=
fields.CharField
(max_length
=255, null=True)
username =
fields.CharField
(max_length
=32, null=True)
user_group
=
fields.CharField
(max_length
=255, null=True)
state =
fields.IntField
(null=True)
captain_by_team
: fields.
ReverseRelation
["Team"]
team:
fields.ManyToManyRelation
['Team']
class Meta:
table = "users"
class Team(Model):
team_id
=
fields.IntField
(pk
=True)
team_name
=
fields.CharField
(max_length
=255)
chat:
fields.ForeignKeyRelation
[Chat] =
fields.ForeignKeyField
( '
models.Chat
',
related_name
="team")
captain:
fields.ForeignKeyRelation
[User] =
fields.ForeignKeyField
( "
models.User
",
related_name
="
captain_by_team
")
description =
fields.CharField
(max_length
=255, null=True)
state =
fields.IntField
(null=True)
players:
fields.ManyToManyRelation
[User] = fields.
ManyToManyField
( "
models.User
",
related_name
="team", through="
users_in_teams
" )
S
S
E
S
create table "user" (
id serial,
.....
)
create table team (
id serial,
.....
)
create table user2team (
user_id int references "user"(id),
team_id int references team(id)
)
S
E
С
create table "user" (
id serial,
.....
)
create table team (
id serial,
.....
)
create table user2team (
user_id int references "user"(id),
team_id int references team(id)
)
S
С
AR
S
ЮЧ
С