我正在为多个客户使用设计应用程序。我最终使用每个客户布局的架构创建了单个数据库设置,如下所示:
CREATE TABLE public.companies
(
id serial NOT NULL,
name long_name NOT NULL,
registration_number character(11),
address character varying(256),
CONSTRAINT "CompaniesPrimaryKey" PRIMARY KEY (id )
);
CREATE TABLE public.banks(.. );
CREATE TABLE public.calendars(.. );
-- Schema definition - none of the tables have company_id key
-- company_1 schema
CREATE TABLE company_1.employees
(
id serial NOT NULL,
first_name character varying(30),
middle_name character varying(30),
last_name character varying(50),
bank_id integer,
CONSTRAINT employees_pkey PRIMARY KEY (id )
);
CREATE TABLE company_1.contracts
(
id serial NOT NULL,
employee_id integer,
calendar_id integer,
CONSTRAINT contracts_pkey PRIMARY KEY (id )
)
-- company_2 schema same as schema company_1
-- and so on ...
在每次讨论中,我都有一些关于数据库设计的争论,有人说它有问题,但没有人能说什么,只是直觉。
它真的有什么问题吗?这种设计的真正警告是什么?