Title: | Relational Data Modeler |
---|---|
Description: | The aim of this package is to manipulate relational data models in R. It provides functions to create, modify and export data models in json format. It also allows importing models created with 'MySQL Workbench' (<https://www.mysql.com/products/workbench/>). These functions are accessible through a graphical user interface made with 'shiny'. Constraints such as types, keys, uniqueness and mandatory fields are automatically checked and corrected when editing a model. Finally, real data can be confronted to a model to check their compatibility. |
Authors: | Patrice Godard [aut, cre, cph], Kai Lin [ctb] |
Maintainer: | Patrice Godard <[email protected]> |
License: | GPL-3 |
Version: | 0.7.6 |
Built: | 2024-11-03 04:36:10 UTC |
Source: | https://github.com/patzaw/redamor |
Subset a RelDataModel
## S3 method for class 'RelDataModel' x[i, rmForeignKeys = FALSE, ...]
## S3 method for class 'RelDataModel' x[i, rmForeignKeys = FALSE, ...]
x |
the RelDataModel objcet |
i |
the index or the names of the elements to extract |
rmForeignKeys |
if TRUE, remove foreign keys which are not available after extraction. If FALSE (default) the function will throw an error if any foreign keys does not exist in the extracted RelDataModel. |
... |
additional arguments for the |
Add a field to a table in a RelDataModel
add_field(x, tableName, name, type, nullable, unique, comment)
add_field(x, tableName, name, type, nullable, unique, comment)
x |
|
tableName |
the name of the table to modify (a single character) |
name |
the name of the field to add (a single character) |
type |
the type of the field (a single character) |
nullable |
if the field is nullable (a single logical) |
unique |
if the values are unique (a single logical) |
comment |
a description (a single character) |
Add a foreign key between two tables
add_foreign_key( x, fromTable, fromFields, toTable, toFields, fmin = 0L, fmax = -1L, tmin = 1L, tmax = 1L )
add_foreign_key( x, fromTable, fromFields, toTable, toFields, fmin = 0L, fmax = -1L, tmin = 1L, tmax = 1L )
x |
|
fromTable |
the name of the referencing table |
fromFields |
the name of the referencing fields |
toTable |
the name of the referenced table |
toFields |
the names of the referenced fields |
fmin |
from minimum cardinality (default: 0L) |
fmax |
from maximum cardinality (default: -1L ==> Infinite) |
tmin |
to minimum cardinality (default: 1L) |
tmax |
to maximum cardinality (default: 1L) |
Add an index to a table in a RelDataModel
add_index(x, tableName, fieldNames, unique)
add_index(x, tableName, fieldNames, unique)
x |
|
tableName |
the name of the table to modify (a single character) |
fieldNames |
the names of the fields to include in the index |
unique |
a logical indicating if the indexed values are unique |
Add a table to a RelDataModel
add_table(x, newTable)
add_table(x, newTable)
x |
|
newTable |
the name of the new table or a RelTableModel |
Convert an object into a specific type
as_type(x, type)
as_type(x, type)
x |
an object to convert |
type |
the targeted type |
Pre-compute RelDataModel layout when missing any x or y table position
auto_layout( x, layout = "layout_nicely", lengthMultiplier = 40 * length(x), force = FALSE )
auto_layout( x, layout = "layout_nicely", lengthMultiplier = 40 * length(x), force = FALSE )
x |
|
layout |
character name of igraph layout function to use (Default: "layout_nicely"). |
lengthMultiplier |
a numeric value to scale x and y coordinate (default: 40*length(x)) |
force |
if TRUE autolayout even if all tables have coordinates (default: FALSE) |
Merge RelDataModel objects
## S3 method for class 'RelDataModel' c(..., checkFK = TRUE)
## S3 method for class 'RelDataModel' c(..., checkFK = TRUE)
... |
RelDataModel objects |
checkFK |
a logical indicating if foreign keys should be checked (default: TRUE) |
A RelDataModel objects
Check the availability of foreign keys
check_foreign_keys(x)
check_foreign_keys(x)
x |
a RelDataModel object |
Nothing. The function throws an error if there is an issue with foreign keys.
Check if a set of types is supported
check_types(x)
check_types(x)
x |
a character vector of types to be checked |
Remove all autosaved RelDataModel
clean_autosaved_RelDataModels()
clean_autosaved_RelDataModels()
Get the types of the columns of a RelTableModel object
col_types(x)
col_types(x)
x |
a RelTableModel object |
A col_spec object with the type of each column
Confront a RelDataModel to actual data
confront_data( x, data = list(), paths = NULL, returnData = FALSE, verbose = TRUE, n_max = Inf, checks = if (n_max == Inf) { c("unique", "not nullable", "foreign keys") } else { as.character() }, delim = "\t", ... )
confront_data( x, data = list(), paths = NULL, returnData = FALSE, verbose = TRUE, n_max = Inf, checks = if (n_max == Inf) { c("unique", "not nullable", "foreign keys") } else { as.character() }, delim = "\t", ... )
x |
|
data |
a list of data frames to be confronted with the model. |
paths |
a character vector with file paths taken into account if the data is empty. The file basename without extension will be considered as the table name. |
returnData |
a logical indicating if the data should be returned with the report (default: FALSE). |
verbose |
a single logical value indicating if some process information should be displayed (default: TRUE) |
n_max |
maximum number of records to read (default: Inf). |
checks |
a character vector with the name of optional checks to be done (Default: if n_max==Inf ==> all of them c("unique", "not nullable", "foreign keys"), else ==> none) |
delim |
single character used to separate fields within a record (default: "\t") |
... |
supplementary parameters for the readr::read_delim function. |
A report as a list
## Read the model ---- hpo_model <- read_json_data_model( system.file("examples/HPO-model.json", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_model, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), returnData=TRUE )
## Read the model ---- hpo_model <- read_json_data_model( system.file("examples/HPO-model.json", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_model, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), returnData=TRUE )
Confront a RelTableModel to actual data
confront_table_data(x, d, checks = c("unique", "not nullable"))
confront_table_data(x, d, checks = c("unique", "not nullable"))
x |
|
d |
a data frame or a matrix for matrix model |
checks |
a character vector with the name of optional checks to be done (Default: all of them c("unique", "not nullable")) |
A report as a list
Convert a set of types from or to R supported types
conv_type_ref(x, from = NULL, to = NULL, ignore.case = TRUE)
conv_type_ref(x, from = NULL, to = NULL, ignore.case = TRUE)
x |
a character vector of types to be converted. If from is not null, x should be a set of valid types in the from reference. If to is not null, x should be a set of supported R types (SUPPTYPES). |
from |
a character vector of length one: the type reference (list_type_ref) of x |
to |
a character vector of length one: the targeted type reference (list_type_ref) |
ignore.case |
should case be ignored when converting 'from“ type reference (default: TRUE) |
Only from
XOR to
should be set
Copy fields from one table to another in a RelDataModel
copy_fields(x, from, to, fields)
copy_fields(x, from, to, fields)
x |
|
from |
the name of the table from which the fields are taken |
to |
the name of the table to which the fields are copied |
fields |
the names of the fields to copy |
Correct the constraints of a table to make them consistent
correct_constraints(x)
correct_constraints(x)
x |
a RelTableModel object |
Create a RelDataModel object from column names of data frames
df_to_model(..., list = character(), pos = -1, envir = as.environment(pos))
df_to_model(..., list = character(), pos = -1, envir = as.environment(pos))
... |
the data frame objects, as names (unquoted) or character strings (quoted) |
list |
a character vector naming data frame objects |
pos |
where to get the objects. By default, uses the current environment. See ‘details’ for other possibilities. |
envir |
the environment to use. See ‘details’. |
The pos argument can specify the environment from which to get the objects in any of several ways: as an integer (the position in the search list); as the character string name of an element in the search list; or as an environment. The envir argument is an alternative way to specify an environment, but is primarily there for back compatibility.
A RelDataModel object.
## Read data files ---- to_read <- list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ) hpo_tables <- list() for(f in to_read){ hpo_tables[[sub("[.]txt$", "", basename(f))]] <- readr::read_tsv(f) } ## Build the model from a list of data frames ---- new_model <- df_to_model( list=names(hpo_tables), envir=as.environment(hpo_tables) ) ## Plot the model ---- new_model %>% auto_layout(lengthMultiplier=250) %>% plot()
## Read data files ---- to_read <- list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ) hpo_tables <- list() for(f in to_read){ hpo_tables[[sub("[.]txt$", "", basename(f))]] <- readr::read_tsv(f) } ## Build the model from a list of data frames ---- new_model <- df_to_model( list=names(hpo_tables), envir=as.environment(hpo_tables) ) ## Plot the model ---- new_model %>% auto_layout(lengthMultiplier=250) %>% plot()
Format confrontation report for printing in console
format_confrontation_report(cr, title = "Model")
format_confrontation_report(cr, title = "Model")
cr |
the confrontation report from confront_data |
title |
a character with a single value corresponding to the report title (e.g. database/model name) |
## Read the model ---- hpo_from_sql <- read_SQL_data_model( system.file("examples/HPO-model.sql", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_from_sql, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), verbose=FALSE, returnData=TRUE ) ## Show the report in console ---- format_confrontation_report(confrontation_report) %>% cat() ## Format the report using markdown ---- format_confrontation_report_md(confrontation_report) %>% cat()
## Read the model ---- hpo_from_sql <- read_SQL_data_model( system.file("examples/HPO-model.sql", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_from_sql, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), verbose=FALSE, returnData=TRUE ) ## Show the report in console ---- format_confrontation_report(confrontation_report) %>% cat() ## Format the report using markdown ---- format_confrontation_report_md(confrontation_report) %>% cat()
Format confrontation report in markdown format
format_confrontation_report_md( cr, title = "Model", level = 0, numbered = TRUE, bgSuccess = "green", txSuccess = "black", bgFailure = "red", txFailure = "white", bgMessage = "#FFBB33", txMessage = "white" )
format_confrontation_report_md( cr, title = "Model", level = 0, numbered = TRUE, bgSuccess = "green", txSuccess = "black", bgFailure = "red", txFailure = "white", bgMessage = "#FFBB33", txMessage = "white" )
cr |
the confrontation report from confront_data |
title |
a character with a single value corresponding to the report |
level |
rmarkdown level in document hierarchy (default:0 ==> highest). It should be an integer between 0 and 4. |
numbered |
a logical. If TRUE (default) the sections are part of document numbering. |
bgSuccess |
background color for SUCCESS |
txSuccess |
text color for SUCCESS |
bgFailure |
background color for FAILURE |
txFailure |
text color for FAILURE |
bgMessage |
background color for a warning message |
txMessage |
text color for a warning message |
## Read the model ---- hpo_from_sql <- read_SQL_data_model( system.file("examples/HPO-model.sql", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_from_sql, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), verbose=FALSE, returnData=TRUE ) ## Show the report in console ---- format_confrontation_report(confrontation_report) %>% cat() ## Format the report using markdown ---- format_confrontation_report_md(confrontation_report) %>% cat()
## Read the model ---- hpo_from_sql <- read_SQL_data_model( system.file("examples/HPO-model.sql", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_from_sql, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), verbose=FALSE, returnData=TRUE ) ## Show the report in console ---- format_confrontation_report(confrontation_report) %>% cat() ## Format the report using markdown ---- format_confrontation_report_md(confrontation_report) %>% cat()
Format a RelTableModel object for printing
## S3 method for class 'RelTableModel' format(x, ...)
## S3 method for class 'RelTableModel' format(x, ...)
x |
a RelTableModel object |
... |
for generics compatibility (not used) |
A single character
Convert a list of 5 normalized tibbles in a RelDataModel object
fromDBM(dbm)
fromDBM(dbm)
dbm |
a list with the following tibbles:
|
A RelDataModel object
Get a foreign key table from an object
get_foreign_keys(x)
get_foreign_keys(x)
x |
a RelTableModel or a RelDataModel |
A tibble with the following fields:
from: the origin of the key
ff: the key fields in from
to: the target of the key
tf: the key fields in to
fmin: minimum cardinality of from
fmax: maximum cardinality of from
tmin: minimum cardinality of to
tmax: maximum cardinality of to
Get foreign keys in RelDataModel
## S3 method for class 'RelDataModel' get_foreign_keys(x)
## S3 method for class 'RelDataModel' get_foreign_keys(x)
x |
A tibble with the following fields:
from: the origin of the key
ff: the key fields in from
to: the target of the key
tf: the key fields in to
fmin: minimum cardinality of from
fmax: maximum cardinality of from
tmin: minimum cardinality of to
tmax: maximum cardinality of to
Get foreign keys from RelTableModel
## S3 method for class 'RelTableModel' get_foreign_keys(x)
## S3 method for class 'RelTableModel' get_foreign_keys(x)
x |
A tibble with the following fields:
from: the origin of the key
ff: the key fields in from
to: the target of the key
tf: the key fields in to
fmin: minimum cardinality of from
fmax: maximum cardinality of from
tmin: minimum cardinality of to
tmax: maximum cardinality of to
Check if two RelDataModel are identical
identical_RelDataModel(x, y, ...)
identical_RelDataModel(x, y, ...)
x |
|
y |
|
... |
additional parameters for |
A logical: TRUE if the 2 models are identical
Check if two RelTableModel are identical
identical_RelTableModel(x, y, includeDisplay = TRUE)
identical_RelTableModel(x, y, includeDisplay = TRUE)
x |
|
y |
|
includeDisplay |
a single logical (default: TRUE) indicating if the display should be included in the comparison |
A logical: TRUE if the 2 models are identical
List indexes of a RelTableModel object
index_table(x)
index_table(x)
x |
a RelTableModel object |
A tibble with the following columns:
index: an integer corresponding to the index number
field: a character corresponding to field belonging to the index
unique: a logical indicating the uniqueness of the field
Identify if a file is in MatrixMarket text format
is_MM(file)
is_MM(file)
file |
the file to read |
A logical. If FALSE, the first line of the file is returned as
an attribute named "r1": attr(is_MM, "r1")
A matrix model is a special RelTableModel object with 3 and only 3 fields: 2 of types 'row' and 'column' and the 3rd of your choice.
is.MatrixModel(x)
is.MatrixModel(x)
x |
any object |
A single logical: TRUE if x is a RelTableModel matrix object
Check if the object is a RelDataModel object
is.RelDataModel(x)
is.RelDataModel(x)
x |
any object |
A single logical: TRUE if x is a RelDataModel object
Check if the object is a RelTableModel object
is.RelTableModel(x)
is.RelTableModel(x)
x |
any object |
A single logical: TRUE if x is a RelTableModel object
Lengths of object elements
lengths(x, use.names = TRUE)
lengths(x, use.names = TRUE)
x |
an object. If there is no method implemented for this object,
the |
use.names |
logical indicating if the result should inherit the names from x. |
A non-negative integer of length length(x), except when any element has a length of more than 2^31 - 1 elements, when it returns a double vector. When use.names is true, the names are taken from the names on x, if any.
List autosaved RelDataModel
list_autosaved_RelDataModel()
list_autosaved_RelDataModel()
clean_autosaved_RelDataModels()
to clean this list.
List supported types references
list_type_ref()
list_type_ref()
Relational data modeler GUI
model_relational_data( modelInput = RelDataModel(list()), fromR = interactive(), defaultColor = "#D9D9D9", availableColors = c("#9BC8FE", "#F67FC4", "#C6BDF1", "#DFFB86", "#F8DEC3", "#8FE6E0", "#FEFE8F", "#FAC6DC", "#A9ECC9"), example = system.file("examples/HPO-model.json", package = utils::packageName()), forceIntro = FALSE )
model_relational_data( modelInput = RelDataModel(list()), fromR = interactive(), defaultColor = "#D9D9D9", availableColors = c("#9BC8FE", "#F67FC4", "#C6BDF1", "#DFFB86", "#F8DEC3", "#8FE6E0", "#FEFE8F", "#FAC6DC", "#A9ECC9"), example = system.file("examples/HPO-model.json", package = utils::packageName()), forceIntro = FALSE )
modelInput |
the RelDataModel to start from |
fromR |
a logical indicating if the application is launched from R |
defaultColor |
a single color indicating the default table color |
availableColors |
a character of possible colors for tables |
example |
a file path to an sql or json model |
forceIntro |
if TRUE the help tour start when the application is launched (default: FALSE) |
The RelDataModel designed with the GUI.
VisNetwork representation of a RelDataModel object
modelToVn( model, color = "lightgrey", border = "black", highlightBorder = "orange" )
modelToVn( model, color = "lightgrey", border = "black", highlightBorder = "orange" )
model |
|
color |
default table background color |
border |
border color (single character) |
highlightBorder |
color of highlighted borders Internal function |
Normalize type names
norm_type_ref(x, typeRef, ignore.case = TRUE)
norm_type_ref(x, typeRef, ignore.case = TRUE)
x |
a character vector to normalize |
typeRef |
a character vector of length one: the type reference (list_type_ref) |
ignore.case |
should case be ignored (default: TRUE) |
Order fields in a table in a RelDataModel
order_fields(x, tableName, order)
order_fields(x, tableName, order)
x |
|
tableName |
the name of the table to modify (a single character) |
order |
a vector of integers all in (1:number_of_fields) |
This function draw a visNetwork of the RelDataModel.
## S3 method for class 'RelDataModel' plot(x, ...)
## S3 method for class 'RelDataModel' plot(x, ...)
x |
|
... |
additional parameters:
|
## Read the model ---- hpo_model <- read_json_data_model( system.file("examples/HPO-model.json", package="ReDaMoR") ) ## Plot the model ---- plot(hpo_model)
## Read the model ---- hpo_model <- read_json_data_model( system.file("examples/HPO-model.json", package="ReDaMoR") ) ## Plot the model ---- plot(hpo_model)
Read a data model from JSON
read_json_data_model(txt)
read_json_data_model(txt)
txt |
a JSON string, URL or file |
## Read the model ---- hpo_model <- read_json_data_model( system.file("examples/HPO-model.json", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_model, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), returnData=TRUE )
## Read the model ---- hpo_model <- read_json_data_model( system.file("examples/HPO-model.json", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_model, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), returnData=TRUE )
Read a named sparse matrix in MatrixMarket text format
read_named_MM( file, skip = 0, n_max = Inf, class = c("dgCMatrix", "tibble"), guess_max = 20 )
read_named_MM( file, skip = 0, n_max = Inf, class = c("dgCMatrix", "tibble"), guess_max = 20 )
file |
the file to read |
skip |
the number of records to skip (default: 0) |
n_max |
the maximum number of records to read (default: Inf) |
class |
the class of object to return. By default a "dgCMatrix". If "tibble" is chosen, the sparse matrix is returned as a tibble with 3 columns: i (row index), j (column index) and x (values) and an "header" attribute containing the matrix rownames and colnames. |
guess_max |
the number of lines to read to find the header.
(see |
By default a dgCMatrix. If the "tibble" class is chosen, the sparse matrix is returned as a tibble with 3 columns: i (row index), j (column index) and x (values) and an "header" attribute containing the matrix rownames and colnames.
Read the header of a named sparse matrix in MatrixMarket text format
read_named_MM_header(file, guess_max = 20)
read_named_MM_header(file, guess_max = 20)
file |
the file to read |
guess_max |
the number of lines to read to find the header. (4 should be sufficient. Default: 20) |
A list with the following fields:
rownames: a character vector with the matrix row names
colnames: a character vector with the matrix column names
rows: the number of matrix rows
columns: the number of matrix columns
values: the number of values in the matrix
header_length: the number of lines in the header
Read a data model from an SQL file from the MySQL Workbench
read_SQL_data_model(f, typeRef = "MySQLWB", mysqlcomments = TRUE) readSQLDataModel(...)
read_SQL_data_model(f, typeRef = "MySQLWB", mysqlcomments = TRUE) readSQLDataModel(...)
f |
the SQL file to read |
typeRef |
the reference for type conversion
(Default: "MySQLWB"; see |
mysqlcomments |
if MySQL comments (starting with #) should be removed (Default: TRUE) |
... |
params for |
Database, table and field names should be surrounded by "'".
A RelDataModel object
readSQLDataModel()
: Deprecated version of read_SQL_data_model
## Read the model ---- hpo_from_sql <- read_SQL_data_model( system.file("examples/HPO-model.sql", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_from_sql, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), returnData=TRUE )
## Read the model ---- hpo_from_sql <- read_SQL_data_model( system.file("examples/HPO-model.sql", package="ReDaMoR") ) ## Confront to data ---- confrontation_report <- confront_data( hpo_from_sql, path=list.files( system.file("examples/HPO-subset", package="ReDaMoR"), full.names=TRUE ), returnData=TRUE )
Recover an autosaved RelDataModel
recover_RelDataModel(name = NA)
recover_RelDataModel(name = NA)
name |
The name of the autosaved RelDataModel to bring back.
Available autosaved RelDataModel can be listed using
the |
Create a RelDataModel object
RelDataModel(l, checkFK = TRUE)
RelDataModel(l, checkFK = TRUE)
l |
the list of table models (RelTableModel objects) |
checkFK |
a logical indicating if foreign keys should be checked (default: TRUE) |
A RelDataModel object.
Create a RelTableModel object
RelTableModel( l = NULL, tableName, fields, primaryKey = NULL, foreignKeys = NULL, indexes = NULL, display = list(x = as.numeric(NA), y = as.numeric(NA), color = as.character(NA), comment = as.character(NA)) )
RelTableModel( l = NULL, tableName, fields, primaryKey = NULL, foreignKeys = NULL, indexes = NULL, display = list(x = as.numeric(NA), y = as.numeric(NA), color = as.character(NA), comment = as.character(NA)) )
l |
DEPRECATED. A named list with the function parameters.
If |
tableName |
a character vector of length one |
fields |
a tibble with the following columns:
|
primaryKey |
a character vector of any length. All values should be in fields$name |
foreignKeys |
a list of foreign keys. Each foreign key is defined as a list with the following elements:
|
indexes |
a list of indexes. Each index is defined by 3 columns:
|
display |
a list gathering:
|
When defining a matrix, 3 and only 3 fields must be defined: 2 of types 'row' and 'column' and the 3rd of your choice. In this case primaryKey is defined automatically as the combination of row and column.
A RelTableModel object.
Remove a field from a table in a RelDataModel
remove_field(x, tableName, fieldName, rmForeignKeys = FALSE)
remove_field(x, tableName, fieldName, rmForeignKeys = FALSE)
x |
|
tableName |
the name of the table to modify (a single character) |
fieldName |
the name of the field to remove (a single character) |
rmForeignKeys |
a single logical indicating if the corresponding foreign keys should be removed. If FALSE (default), the function will throw an error if it encounter a foreign key using the field. |
Remove a foreign key between two tables
remove_foreign_key(x, fromTable, fromFields, toTable, toFields)
remove_foreign_key(x, fromTable, fromFields, toTable, toFields)
x |
|
fromTable |
the name of the referencing table |
fromFields |
the name of the referencing fields |
toTable |
the name of the referenced table |
toFields |
the names of the referenced fields |
Remove an index from a table in a RelDataModel
remove_index(x, tableName, fieldNames)
remove_index(x, tableName, fieldNames)
x |
|
tableName |
the name of the table to modify (a single character) |
fieldNames |
the names of the fields composing the index |
Remove a table from a RelDataModel
remove_table(x, tableName, rmForeignKeys = FALSE)
remove_table(x, tableName, rmForeignKeys = FALSE)
x |
|
tableName |
the name of the table to remove |
rmForeignKeys |
if TRUE, remove foreign keys which are not available after extraction. If FALSE (default) the function will throw an error if any foreign keys does not exist in the extracted RelDataModel. |
Rename an existing field in a RelDataModel table
rename_field(x, tableName, current, new)
rename_field(x, tableName, current, new)
x |
|
tableName |
the name of the table to modify (a single character) |
current |
the current name of the field to modify (a single character) |
new |
the new name of the field (a single character) |
Rename a table in a RelDataModel
rename_table(x, old, new)
rename_table(x, old, new)
x |
a RelDataModel object |
old |
a single character corresponding to the table name to change |
new |
the new table name |
Set the primary key a table in a RelDataModel
set_primary_key(x, tableName, fieldNames)
set_primary_key(x, tableName, fieldNames)
x |
|
tableName |
the name of the table to modify (a single character) |
fieldNames |
the names of the fields to include in the primary key |
Set table index uniqueness in a RelDataModel
set_unique_index(x, tableName, fieldNames, unique)
set_unique_index(x, tableName, fieldNames, unique)
x |
|
tableName |
the name of the table to modify (a single character) |
fieldNames |
the names of the fields composing the index |
unique |
a logical value |
Supported R types
SUPPTYPES
SUPPTYPES
An object of class character
of length 7.
Convert a RelDataModel object in a list of 5 normalized tibbles
toDBM(rdm)
toDBM(rdm)
rdm |
a RelDataModel object |
A list with the following tibbles:
tables: The tables in the model with the following information
name: the name of the table
x: the x coordinate of the table in the model drawing (NA ==> position undefined)
y: the y coordinate of the table in the model drawing (NA ==> position undefined)
color: the color of the table in the model drawing (NA ==> undefined)
comment: comment about the table
fields: The fields in the model with the following information
name: the name of the field
type: the type of the field
nullable: a logical indicating if the field can be null
comment: comment about the field
table: the name of the table to which the field belongs
primaryKeys: The primary keys in the model with the following information
table: the name of the relevant table
field: the name of the field participating to the primary key
foreignKeys: The foreign keys in the model with the following information
table: the name of the referring table
fki: the identifier of the foreign key (by referring table)
field: the name of the referring field
refTable: the name of the referred table
refField: the name of the referred field
indexes: The indexes in the model with the following information
table: the name of the relevant table
idx: the identifier of the index (by table)
field: the name of the field participating to the index
unique: a logical indicating if the field is unique
Update field information in a table of a RelDataModel
update_field( x, tableName, fieldName, type = NULL, nullable = NULL, unique = NULL, comment = NULL )
update_field( x, tableName, fieldName, type = NULL, nullable = NULL, unique = NULL, comment = NULL )
x |
|
tableName |
the name of the table to modify (a single character) |
fieldName |
the name of the field to modify (a single character) |
type |
the type of the field (a single character) |
nullable |
if the field is nullable (a single logical) |
unique |
if the values are unique (a single logical) |
comment |
a description (a single character) |
Update a the cardinalities of a foreign key between two tables
update_foreign_key( x, fromTable, fromFields, toTable, toFields, fmin, fmax, tmin, tmax )
update_foreign_key( x, fromTable, fromFields, toTable, toFields, fmin, fmax, tmin, tmax )
x |
|
fromTable |
the name of the referencing table |
fromFields |
the name of the referencing fields |
toTable |
the name of the referenced table |
toFields |
the names of the referenced fields |
fmin |
from minimum cardinality |
fmax |
from maximum cardinality |
tmin |
to minimum cardinality |
tmax |
to maximum cardinality |
Update the display of a table of a RelDataModel
update_table_display( x, tableName, px = NULL, py = NULL, color = NULL, comment = NULL )
update_table_display( x, tableName, px = NULL, py = NULL, color = NULL, comment = NULL )
x |
|
tableName |
the name of the table to modify (a single character) |
px |
the position of the table: x value |
py |
the position of the table: y value |
color |
the color of the table |
comment |
a table description/comment |
View confrontation report in rstudio viewer
view_confrontation_report(cr, ...)
view_confrontation_report(cr, ...)
cr |
the confrontation report from confront_data |
... |
additional params for
the |
Write a data model in a JSON file
write_json_data_model(x, path)
write_json_data_model(x, path)
x |
the model to be written |
path |
file on disk |