USE [master] GO /****** Object: Database [SQLClassRev] Script Date: 11/14/2023 1:42:40 PM ******/ CREATE DATABASE [SQLClassRev1] GO USE [SQLClassRev] GO /****** Object: Table [dbo].[Customers] Script Date: 11/14/2023 1:42:41 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Customers]( [cust_id] [int] IDENTITY(1,1) NOT NULL, [cust_number] [char](50) NOT NULL, [cust_name] [char](50) NOT NULL, [cust_address] [char](50) NULL, [cust_city] [char](50) NULL, [cust_state] [char](5) NULL, [cust_zip] [char](10) NULL, [cust_country] [char](50) NULL, [cust_contact] [char](50) NULL, [cust_email] [char](255) NULL, CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED ( [cust_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[OrderItems] Script Date: 11/14/2023 1:42:41 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[OrderItems]( [orderitem_id] [int] IDENTITY(1,1) NOT NULL, [order_num] [int] NOT NULL, [order_item] [int] NOT NULL, [quantity] [int] NOT NULL, [item_price] [decimal](8, 2) NOT NULL, [prod_id] [int] NOT NULL, [order_id] [int] NOT NULL, CONSTRAINT [PK_OrderItems] PRIMARY KEY CLUSTERED ( [orderitem_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Orders] Script Date: 11/14/2023 1:42:41 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Orders]( [order_id] [int] IDENTITY(1,1) NOT NULL, [order_num] [int] NOT NULL, [order_date] [datetime] NOT NULL, [cust_id] [int] NOT NULL, CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED ( [order_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Products] Script Date: 11/14/2023 1:42:41 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Products]( [prod_id] [int] IDENTITY(1,1) NOT NULL, [vend_id] [int] NOT NULL, [prod_number] [char](50) NOT NULL, [prod_name] [char](255) NOT NULL, [prod_price] [decimal](8, 2) NOT NULL, [prod_desc] [varchar](1000) NULL, CONSTRAINT [PK_Products] PRIMARY KEY CLUSTERED ( [prod_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO /****** Object: Table [dbo].[Vendors] Script Date: 11/14/2023 1:42:41 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Vendors]( [vend_id] [int] IDENTITY(1,1) NOT NULL, [vend_number] [char](50) NOT NULL, [vend_name] [char](50) NOT NULL, [vend_address] [char](50) NULL, [vend_city] [char](50) NULL, [vend_state] [char](5) NULL, [vend_zip] [char](10) NULL, [vend_country] [char](50) NULL, CONSTRAINT [PK_Vendors] PRIMARY KEY CLUSTERED ( [vend_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[OrderItems] WITH CHECK ADD CONSTRAINT [FK_OrderItems_Orders] FOREIGN KEY([order_id]) REFERENCES [dbo].[Orders] ([order_id]) GO ALTER TABLE [dbo].[OrderItems] CHECK CONSTRAINT [FK_OrderItems_Orders] GO ALTER TABLE [dbo].[OrderItems] WITH CHECK ADD CONSTRAINT [FK_OrderItems_Products] FOREIGN KEY([prod_id]) REFERENCES [dbo].[Products] ([prod_id]) GO ALTER TABLE [dbo].[OrderItems] CHECK CONSTRAINT [FK_OrderItems_Products] GO ALTER TABLE [dbo].[Orders] WITH CHECK ADD CONSTRAINT [FK_Orders_Customers] FOREIGN KEY([cust_id]) REFERENCES [dbo].[Customers] ([cust_id]) GO ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK_Orders_Customers] GO ALTER TABLE [dbo].[Products] WITH CHECK ADD CONSTRAINT [FK_Products_Vendors] FOREIGN KEY([vend_id]) REFERENCES [dbo].[Vendors] ([vend_id]) GO ALTER TABLE [dbo].[Products] CHECK CONSTRAINT [FK_Products_Vendors] GO USE [master] GO ALTER DATABASE [SQLClassRev] SET READ_WRITE GO