i have these 2 sql for creating 2 tables in my database, what i have to write to show that is one to many relationsip? [one supplier to many order status]

CREATE TABLE Suppliers(

SupplierID nVarChar(10) NOT NULL CONSTRAINT Suppliers_PK PRIMARY KEY,

CompanyName nvarchar(40) NOT NULL,

Description nvarchar(100) NULL,

SortOrder int NOT NULL DEFAULT(50),

Active bit NOT NULL DEFAULT (1)

)

GO

CREATE TABLE OrderStatus(

OrderStatus nChar(10) NOT NULL CONSTRAINT OrderStatus_PK PRIMARY KEY,

Status nvarchar(40) NOT NULL,

Description nvarchar(100) NULL,

SortOrder int NOT NULL DEFAULT(50),

Active bit NOT NULL DEFAULT (1)

)

/* ============================================================ */
/*   Table: SUPPLIERS                                           */
/* ============================================================ */
create table SUPPLIERS
(
    SUPPLIERID                      varchar(10)           not null,
    COMPANYNAME                     varchar(40)           not null,
    DESCRIPTION                     varchar(100)          null    ,
    SORTORDER                       int                   not null,
    ACTIVE                          tinyint               not null,
    constraint PK_SUPPLIERS primary key (SUPPLIERID)
)
go

/* ============================================================ */
/*   Table: ORDERSTATUS                                         */
/* ============================================================ */
create table ORDERSTATUS
(
    ORDERSTATUS                     varchar(10)           not null,
    SUPPLIERID                      varchar(10)           null    ,
    STATUS                          varchar(40)           not null,
    DESCRIPTION                     varchar(100)          null    ,
    SORTORDER                       int                   not null,
    ACTIVE                          tinyint               not null,
    constraint PK_ORDERSTATUS primary key (ORDERSTATUS)
)
go

/* ============================================================ */
/*   Index: RELATION_20_FK                                      */
/* ============================================================ */
create index RELATION_20_FK on ORDERSTATUS (SUPPLIERID)
go

alter table ORDERSTATUS
    add constraint FK_RELATION_20 foreign key  (SUPPLIERID)
       references SUPPLIERS (SUPPLIERID)
go

pikkas, actually you post in wrong forum. you should post in Database forums.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.