
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 04/25/2010 19:05:21
-- Generated from EDMX file: E:\Programy\ksiazka\Entity Framework\VS2010_EFv4\Projekty\Projekt_NajpierwModel\Projekt_NajpierwModel\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [AdventureWorks];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------


-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'ProduktSet'
CREATE TABLE [dbo].[ProduktSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nazwa] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'ZamówienieSet'
CREATE TABLE [dbo].[ZamówienieSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nazwa] nvarchar(max)  NOT NULL,
    [Produkt_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'ProduktSet'
ALTER TABLE [dbo].[ProduktSet]
ADD CONSTRAINT [PK_ProduktSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ZamówienieSet'
ALTER TABLE [dbo].[ZamówienieSet]
ADD CONSTRAINT [PK_ZamówienieSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [Produkt_Id] in table 'ZamówienieSet'
ALTER TABLE [dbo].[ZamówienieSet]
ADD CONSTRAINT [FK_ProduktZamówienie]
    FOREIGN KEY ([Produkt_Id])
    REFERENCES [dbo].[ProduktSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ProduktZamówienie'
CREATE INDEX [IX_FK_ProduktZamówienie]
ON [dbo].[ZamówienieSet]
    ([Produkt_Id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------