starschemar (version 1.2.0)

role_playing_dimension: Define a role playing dimension in a star_schema object

Description

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

Run this code
# NOT RUN {
library(tidyr)

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")
  )

# }

Run the code above in your browser using DataCamp Workspace