merge_schemas: Merge relation schemas in given pairs

View source: R/shared_class_functions.r

merge_schemasR Documentation

Merge relation schemas in given pairs

Description

Generic function that merges pairs of an object's schemas with matching sets of keys. The remaining schemas contain all the attributes from the schemas merged into them.

Usage

merge_schemas(x, to_remove, merge_into, ...)

Arguments

x

a relational schema object, such as a relation_schema or database_schema object.

to_remove

an integer vector, giving the indices for schemas to be merged into other schemas, then removed.

merge_into

an integer vector of the same length as to_remove, giving the indices for the schemas into which to merge.

...

further arguments passed on to methods.

Value

An R object of the same class as x, where the relations have been merged as indicated.

See Also

merge_empty_keys, which is based on this function.

Examples

rs <- relation_schema(
  list(
    a = list(c("a", "b"), list("a")),
    b = list(c("b", "c"), list("b")),
    b.1 = list(c("b", "d"), list("b")),
    d = list(c("d", "e"), list("d", "e"))
  ),
  letters[1:5]
)
ds <- database_schema(
  rs,
  list(
    list("a", "b", "b", "b"),
    list("b.1", "d", "d", "d")
   )
)
merge_schemas(rs, 3, 2) # merging b and b.1
merge_schemas(ds, 3, 2) # also merging their references

# merging a schema into itself just removes it
merge_schemas(rs, 3, 3)
merge_schemas(ds, 3, 3)

autodb documentation built on April 4, 2025, 5:12 a.m.