SQL Server schema diagrams from a scripted database
Bracketed identifiers, bracketed type names and clustered primary keys with a sort direction, read the way SSMS scripts them.
What the parser makes of it
- 2 tables
- 8 columns
- 1 relation
[dbo].[Customer]bracket quoting, on tables, columns and types alike[int] IDENTITY(1,1)and parameterised[numeric](10, 2)CONSTRAINT … PRIMARY KEY CLUSTERED ([CustomerId] ASC), sort direction and all- foreign keys added by a separate
ALTER TABLE … ADD CONSTRAINTstatement
The diagram
draft render, on this page's build.The file
This is the project's SQL Server test fixture, in full and unedited. Everything above was produced from it.
/* SQL Server: bracketed identifiers everywhere, including the types, and
PRIMARY KEY CLUSTERED with a sort direction inside the column list. */
CREATE TABLE [dbo].[Customer](
[CustomerId] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [nvarchar](40) NOT NULL,
[Email] [nvarchar](60) NULL,
[SupportRepId] [int] NULL,
CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED ([CustomerId] ASC)
);
CREATE TABLE [dbo].[Invoice](
[InvoiceId] [int] IDENTITY(1,1) NOT NULL,
[CustomerId] [int] NOT NULL,
[BillingAddress] [nvarchar](70) NULL,
[Total] [numeric](10, 2) NOT NULL,
CONSTRAINT [PK_Invoice] PRIMARY KEY CLUSTERED ([InvoiceId] ASC)
);
ALTER TABLE [dbo].[Invoice] ADD CONSTRAINT [FK_InvoiceCustomer]
FOREIGN KEY([CustomerId]) REFERENCES [dbo].[Customer] ([CustomerId]);