Changes between Version 2 and Version 3 of ddlScript.sql


Ignore:
Timestamp:
12/16/24 01:21:27 (4 weeks ago)
Author:
211101
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ddlScript.sql

    v2 v3  
    1 
    21{{{#!sql
    32-- Delete tables if they exist
     
    2524);
    2625
     26-- Create TRANSACTION table
     27CREATE TABLE transaction (
     28    transaction_id SERIAL PRIMARY KEY,
     29    transaction_name VARCHAR(100),
     30    amount DECIMAL(10, 2) NOT NULL,
     31    net_amount DECIMAL(10, 2),
     32    date TIMESTAMPTZ NOT NULL
     33);
     34
    2735-- Create TAG table
    2836CREATE TABLE tag (
     
    3139);
    3240
    33 -- Create TRANSACTION table
    34 CREATE TABLE transaction (
    35     transaction_id SERIAL PRIMARY KEY,
    36     transaction_name VARCHAR(100),
    37     amount DECIMAL(10, 2) NOT NULL,
    38     net_amount DECIMAL(10, 2),
    39     date TIMESTAMPTZ,
    40     tag_id INT REFERENCES tag(tag_id)
     41-- Create TAG_ASSIGNED_TO_TRANSACTION table
     42CREATE TABLE tag_assigned_to_transaction (
     43    tag_assigned_to_transaction_id SERIAL PRIMARY KEY,
     44    transaction_id INT NOT NULL REFERENCES transaction(transaction_id) ON DELETE CASCADE,
     45    tag_id INT NOT NULL REFERENCES tag(tag_id) ON DELETE CASCADE
    4146);
    4247
     
    4954    earned_amount DECIMAL(10, 2)
    5055);
    51 
    52 -- Create TAG_ASSIGNED_TO_TRANSACTION table
    53 CREATE TABLE tag_assigned_to_transaction (
    54     tag_assigned_to_transaction_id SERIAL PRIMARY KEY,
    55     tag_id INT REFERENCES tag(tag_id),
    56     transaction_id INT REFERENCES transaction(transaction_id)
    57 );
    5856}}}