0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

会計ソフトの作成 2 貸借の表現

0
Posted at

プログラム言語内なら定数としてもってしまえば良いのでしょうが、「借方」「貸方」の両者をテーブルで保持して参照させる形をとります。
あるテーブルで[借方=>1 貸方=>2],別なテーブルでは、[借方=>'A' 貸方=>'B']などというような事態を避けるためです。

CREATE TABLE kaikei."type_貸借" (                                                             
    id text NOT NULL,
    "貸借" text NOT NULL
);

INSERT INTO kaikei."type_貸借" VALUES ('1', '借方'); 
INSERT INTO kaikei."type_貸借" VALUES ('2', '貸方'); 
ALTER TABLE ONLY kaikei."type_貸借" 
    ADD CONSTRAINT "p_type_貸借" PRIMARY KEY (id);

このテーブルの内容を編集することはまず無いので、id列はserialをとりませんでした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?