Skip to contents

Given a list of star_schema dimension names, all with the same structure, a role playing dimension with the indicated name and attributes is generated. The original dimensions become role dimensions defined from the new role playing dimension.

Usage

role_playing_dimension(st, dim_names, name = NULL, attributes = NULL)

# S3 method for star_schema
role_playing_dimension(st, dim_names, name = NULL, attributes = NULL)

Arguments

st

A star_schema object.

dim_names

A vector of dimension names.

name

A string, name of the role playing dimension.

attributes

A vector of attribute names of the role playing dimension.

Value

A star_schema object.

Details

After definition, all role dimensions have the same virtual instances (those of the role playing dimension). The foreign keys in facts are adapted to this new situation.

See also

Other star schema and constellation definition functions: character_dimensions(), constellation(), snake_case(), star_schema()

Examples


st <- star_schema(mrs_age, dm_mrs_age) |>
  role_playing_dimension(
    dim_names = c("when", "when_available"),
    name = "When Common",
    attributes = c("Date", "Week", "Year")
  )

st <- star_schema(mrs_cause, dm_mrs_cause) |>
  role_playing_dimension(
    dim_names = c("when", "when_received", "when_available"),
    name = "when_common",
    attributes = c("date", "week", "year")
  )