---
name: "Parse::Dia::SQL::Output::SQLite3fk"
section: "3pm"
platform: "linux"
package: "libparse-dia-sql-perl"
version: "0.31-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Parse::Dia::SQL::Output::SQLite3fk"
---

# Parse::Dia::SQL::Output::SQLite3fk(3pm)

Create SQL for SQLite version 3, with foreign key support

## NAME

Parse::Dia::SQL::Output::SQLite3fk - Create SQL for SQLite version 3, with foreign key support

## SYNOPSIS

```
    use Parse::Dia::SQL;
    my $dia = Parse::Dia::SQL->new(file => 'foo.dia', db => 'sqlite3fk');
    print $dia->get_sql();
```

## DESCRIPTION

This sub-class creates SQL for the SQLite database version 3.

### new

The constructor.

Object names in SQLite have no inherent limit. 60 has been arbitrarily chosen.

### \_get\_create\_table\_sql

Generate create table statement for a single table using SQLite syntax:

Includes class comments before the table definition.

Includes autoupdate triggers based on the class comment.

Includes foreign key support of the form

```
  foreign key(thisColumn)  references thatTable(thatColumn) {action}
```

Where {action} is the optional contraint condition, such as 'on delete cascade' exactly as entered in the diagram.

*autoupdate triggers*

If the class comment includes a line like:

\<autoupdate:*foo*/\>

Then an 'after update' trigger is generated for this table which executes the statement *foo* for the updated row.

Examples of use include tracking record modification dates (`"<autoupdate:dtModified=datetime('now')/"`\>) or deriving a value from another field (`"<autoupdate:sSoundex=soundex(sName)/"`\>)

### \_create\_pk\_string

Override default function to include foreign key clauses

### get\_schema\_drop

Generate drop table statements for all tables using SQLite syntax:

```
  drop table {foo} if exists
```

### get\_view\_drop

Generate drop view statements for all tables using SQLite syntax:

```
  drop view {foo} if exists
```

### \_get\_fk\_drop

Foreign key enforcement is embedded in the table definitions for SQLite, so no output is required here.

### \_get\_drop\_index\_sql

drop index statement using SQLite syntax:

```
  drop index {foo} if exists
```

### get\_permissions\_create

SQLite doesn't support permissions, so suppress this output.

### get\_permissions\_drop

SQLite doesn't support permissions, so suppress this output.

### \_get\_create\_association\_sql

Foreign key enforcement is embedded in the table definitions for SQLite, so no output is required here.

## TODO

Things that might get added in future versions:

*Views*

Views haven't been tested. They might already work, but who knows...

*Other stuff*

Bugs etc
