Skip to content

Example.Database

IzayoiJiichan edited this page Aug 15, 2024 · 2 revisions

Examples

Database

-- SQL Server Example
CREATE TABLE [dbo].[users] (
    [id]         INT           IDENTITY (1, 1) NOT NULL,
    [name]       NVARCHAR (50) NOT NULL,
    [age]        TINYINT       NOT NULL,
    [gender]     TINYINT       NOT NULL,
    [created_at] DATETIME2 (7) NOT NULL,
    [updated_at] DATETIME2 (7) NOT NULL,
    PRIMARY KEY CLUSTERED ([id] ASC)
);

CREATE TABLE [dbo].[posts] (
    [id]        INT            IDENTITY (1, 1) NOT NULL,
    [posted_at] DATETIME2 (7)  NOT NULL,
    [user_id]   INT            NOT NULL,
    [comment]   NVARCHAR (100) NOT NULL,
    PRIMARY KEY CLUSTERED ([id] ASC)
);