datamodelr (version 0.2.1.9001)

as.data_model: Coerce to a data model

Description

Functions to coerce an object to a data model if possible.

Usage

as.data_model(x)

Arguments

x

Object (list or data frame) to be coerced to data model object

Value

If possible it returns a data model object. It is a list of data frames with at least the following columns:

column

A name of the column in a table

key

A boolean value indicating this column is a primary key or NA.

ref

A character string with a referenced table name. Not being NA means the column is a foreign key.

Details

Function accepts a data frame with columns info. Data frame must have 'table' and 'column' elements. Optional element 'key' (boolean) marks a column as a primary key. Optional element 'ref' (character string) defines referenced table name. Optional element 'ref_col' (character string) defines a column in a referenced table name primary key (only necessery when referenced table has a compound primary key).