Search Postgresql Archives

restruct cash table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I have a small problem with my table: I have a table for my cash and i
do several actions in it. I receive money in different forms, I expend
money in different forms etc. And do each action I have various foreign
keys. But they are not all in use in every column. I don't know how I
can structure the table better:

CREATE TABLE cash (
  id serial,
  type text NOT NULL,
  account text NOT NULL,
  value numeric(10,2) NOT NULL,
  item text,
  department text,
  person text,
  description text
);

In this table is data like this:

ID | type     | account | value   | item  | department   | client   |
---+----------+---------+---------+-------+--------------+----------+
 1 | sale     | acc_1   |   10,00 | paper | department_1 | NULL     |
 2 | deposit  | acc_1   |   15,00 | NULL  | NULL         | client_1 |
 3 | deposit  | acc_2   |   25,00 | NULL  | NULL         | client_2 |
 4 | transfer | acc_2   |  -15,00 | NULL  | NULL         | NULL     |
 5 | transfer | acc_1   |   15,00 | NULL  | NULL         | NULL     |
 6 | purchase | acc_2   |  -12,00 | NULL  | department_3 | NULL     |
 7 | usage    | NULL    |   -1,00 | page  |              | client_1 |
 8 | usage    | NULL    |    1,00 | page  | department_2 | NULL     |
 9 | usage    | NULL    |   -1,00 | page  | department_1 | NULL     |
10 | usage    | NULL    |    1,00 | page  | department_2 | NULL     |

Is there a better way to store this actions?
(type, account, item, department and client have all its own tables)

Thanks,
  Gerhard

Attachment: signature.asc
Description: Digital signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux