% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/schema.R
\name{vtr_schema}
\alias{vtr_schema}
\title{Create a star schema over linked vectra tables}
\usage{
vtr_schema(fact, ...)
}
\arguments{
\item{fact}{A \code{vectra_node} object (the central fact table). Must be
file-backed (created via \code{\link[=tbl]{tbl()}}, \code{\link[=tbl_csv]{tbl_csv()}}, or \code{\link[=tbl_sqlite]{tbl_sqlite()}}).}

\item{...}{Named \code{vectra_link} objects created by \code{\link[=link]{link()}}. Names become
the dimension aliases used in \code{\link[=lookup]{lookup()}} (e.g., \code{species$name}).}
}
\value{
A \code{vectra_schema} object.
}
\description{
Registers a fact table with named dimension links. The schema enables
\code{\link[=lookup]{lookup()}} to resolve columns from dimension tables without writing
explicit joins.
}
\examples{
\donttest{
f_obs <- tempfile(fileext = ".vtr")
f_sp  <- tempfile(fileext = ".vtr")
f_ct  <- tempfile(fileext = ".vtr")
write_vtr(data.frame(sp_id = 1:3, ct_code = c("AT", "DE", "FR"),
                      value = 10:12), f_obs)
write_vtr(data.frame(sp_id = 1:3,
                      name = c("Oak", "Beech", "Pine")), f_sp)
write_vtr(data.frame(ct_code = c("AT", "DE", "FR"),
                      gdp = c(400, 3800, 2700)), f_ct)

s <- vtr_schema(
  fact    = tbl(f_obs),
  species = link("sp_id", tbl(f_sp)),
  country = link("ct_code", tbl(f_ct))
)
print(s)
unlink(c(f_obs, f_sp, f_ct))
}

}
