Untitled
unknown
plain_text
a year ago
1.7 kB
3
Indexable
Never
Create Table Countries ( Id int not null primary key identity, [Name] varchar(10) not null ); Create Table Addresses ( Id int NOT NULL primary key identity, StreetName nvarchar(20) NOT NULL, StreetNumber int NULL, PostCode int NOT NULL, City varchar(25) NOT NULL, CountryId int NOT NULL foreign key references Countries(Id) ); Create Table Vendors ( Id int not null primary key identity, [Name] nvarchar(25) not null, NumberVAT nvarchar(15) NOT NULL, AddressID int NOT NULL foreign key references Addresses(Id) ); create table Clients ( Id int not null primary key identity, [Name] nvarchar(25) NOT NULL, NumberVAT nvarchar(15) NOT NULL, AddressID int NOT NULL foreign key references Addresses(Id) ); Create Table Categories ( Id int NOT NULL identity primary key, [Name] varchar(10) not null ); Create Table Products ( Id int not null primary key identity, [Name] nvarchar(35) not null, Price decimal(18,2) NOT NULL, CategoryID int NOT NULL foreign key references Categories(Id), VendorID int NOT NULL foreign key references Vendors(Id) ); Create Table Invoices ( Id int NOT NULL primary key identity, Number Int unique NOT NULL, IssueDate Datetime2 NOT NULL, DueDate Datetime2 NOT NULL, Amount Decimal(18,2) NOT NULL, Currency varchar(5) NOT NULL, ClientId INT NOT NULL foreign key references Clients(Id) ); CREATE TABLE ProductsClients ( ProductID int NOT NULL foreign key references Products(Id), ClientID int NOT NULL foreign key references Clients(Id), Constraint PK_ProductClients primary key ( ProductId,ClientId) );