Reputation: 1
I'm going to portion a table, but another table have foreign key from this table. let's say I have these two tables and assume I will have millions of rows of data and really need partitioning.
from sqlmodel import Field, SQLModel, create_engine, Session
from typing import Optional
#Table (A)
class A(SQLModel, table=True):
id: int = Field(primary_key=True)
name: str
created_at: Optional[datetime] = Field(default_factory=lambda: datetime.now(timezone.utc))
# Table B with foreign key
class B(SQLModel, table=True):
id: int = Field(primary_key=True)
a_id: int = Field(foreign_key="A.id")
description: str
created_at: Optional[datetime] = Field(default_factory=lambda: datetime.now(timezone.utc))
Is it possible to partition the table for each month (or year) and still have the foreign key (since it should point to different partition).
I check different conversations like:
Upvotes: 0
Views: 34