db_createLinkTable: creates a 'link' table for many to many relations

View source: R/dbAccess.R

db_createLinkTableR Documentation

creates a 'link' table for many to many relations

Description

creates a 'link' table for many to many relations

Usage

db_createLinkTable(
  db,
  tableName = NA,
  leftTableName,
  leftID = defaultPrimaryKey(),
  rightTableName,
  rightID = defaultPrimaryKey(),
  addPrimary = FALSE,
  includeUniqueConstraint = TRUE,
  primaryKeyName = defaultPrimaryKey(),
  dbType = "SQLite"
)

Arguments

db

database access 'handle'

tableName

name of the 'link' table to create. If NA (default), then it will create a name like this: leftTableName_rightTableName

leftTableName

name of the so-called left table

leftID

name of the column in the left table to be used for the relations. This should be a unique identifier, so preferable a primary key

rightTableName

name of the so-called right table

rightID

name of the column in the right table to be used for the relations. This should be a unique identifier, so preferable a primary key

addPrimary

add a autoincremented primary key (default = FALSE)

includeUniqueConstraint

if TRUE, then the two columns containing the foreign keys are set to be unique pairs. Note that this has consequences for the db_writeTable() function

primaryKeyName

name of the primary key if used (default = "id_")

dbType

default is "SQLite", only one alternative ("MySQL") has been tested

Value

nothing

Note

leftID is always column 1, rightID is always column 2


BenBruyneel/BBPersonalR documentation built on Aug. 23, 2024, 8:28 p.m.