我正在开发一个在线数据库建模器,用户可以:
创建新的数据库模式
其特点包括:
我最初想支持MSSql、MySQL、Postgres和SQLite。我想在Postgres中创建这个数据库。我有很少的Postgres经验,我主要是处理MySQL。
以下是我到目前为止得出的结论:
engines
id int( pk )
name varchar(40)发动机样本数据:
(
{"id":1,"name":"postgres"},
{"id":2, "name":"mysql"}
)数据库
id int ( pk )
name varchar(100)
slug varchar(40)
user_id int
description text
engine int ( fk to engines.id )
fork_id int ( keep track of forks )
parent_id int ( this is for revisions )
comment_id int ( fk to comments.id )
created timestamptz(6)
modified timestamptz(6)数据库样本数据:
(
{
"id":1,"name":"my first db",
"slug":"my-first-db",
"user_id":3,
"description":"This is my first database.",
"engine":1,
"created":"2009-09-01 22:22:10",
"modified":"2009-09-01 22:22:10",
"comments":3
}
)表
id int ( pk )
database_id int ( fk to databases.id )
name varchar(40)
x_position int // this is the X position from the top left of the container
y_position int // this is the Y position from the top left of the container表的抽样数据:
(
{"id":1,"name":"customers", "database_id":1, "x_position":1, "y_position":2 }
)字段
id int ( pk )
table_id int ( fk to tables.id )
name varchar(40)
type int ( fk to types.id )
default varchar ( 100 )
size int
autoincrement tinyint(1)
null tinyint(1)字段的样本数据:
(
{"id":1,"name":"id", "type":2, "table_id":1, "autoincrement":1, "null":1 }
)外键
id int ( pk )
origin_field_id int ( fk to fields.id )
remote_field_id int ( fk to fields.id )外键的示例数据:
(
{"id":1,"origin_field_id":2, "remote_field_id":3 }
)类型
id int ( pk )
name varchar(40)外键的示例数据:
(
{"id":1,"name":"BLOB" }
)*types_engines (映射表)*
id int ( pk )
type_id int
engine_id int外键的示例数据:
(
{"id":1,"name":"BLOB" }
)由于我是一个相对新手的SQLer,如果有人能指出我所做的关键设计缺陷,并指出我没有想过,也没有忘记的事情可能是关键的话,我会很感激。这是我需要解决的问题。
fork_id和parent_id。我想跟踪数据库是否是分叉从其他数据库,除了保持对叉子的修订。为了做到这一点,我需要这两种方法吗?我意识到我不支持更高级的特性,比如视图/触发器,但我认为这在其简单的性质上是有用的。
发布于 2010-11-03 00:24:17
如果您希望(创建数据库的)开发人员能够使用SQL的所有功能和工具,那么这是行不通的。你这样做完全是错误的。你做了相当多的工作,设计表格等等,这是必须承认的;但所有这些都是不必要的,但投资可能会阻碍你放弃它。当然,如果您实现了该结构,就必须有人(a)管理它,(b)维护它。
只要您有一个ANSI SQL平台,这些面向开发人员的工具就已经被提供了,经过深思熟虑,完全符合已发布的标准(与您或我可能认为是提供、控制和测试共享对象的好方法相反)。请不要重新发明轮子.
。
- In the server, Grant developers Create\_Database permission.
- They can administer their own _databases_, share them, etc, to their hearts desire.。
在测试任何共享对象将一起工作之前,
- Create Users (one per developer)
- Grant each user Create\_Table (Rule, Proc, etc) permission
- They can administer their own _objects_, share them, etc, to their hearts desire.
- Each object owner is responsible for building objects, and sharing them, and testing them in their Owner area. This is still not the single shared area that is relevant to formal testing before development of formal objects is commenced
- That single shared area, for real testing, is DBO
- As DBA, you only need to manage DBO objects
- no one else is DBO
- When a developer is ready to promote their private object to a formally shared object, they notify you
- you simply copy the DDL of their private object, and execute it as DBO
就这样。管理所需的所有表等都已实现。这是SQL目录。
当然,有许多开发人员和DBA工具,它们允许只需点击几下就可以完成上面的任务。
发布于 2010-11-03 01:39:57
查找元数据管理工具和/或ERWin或其他数据库设计工具
https://stackoverflow.com/questions/4071982
复制相似问题