0% found this document useful (0 votes)
24 views

Perfoums DB

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Perfoums DB

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

USE [master]

GO
/****** Object: Database [perfume] Script Date: 2023-12-28 10:49:10 AM ******/
CREATE DATABASE [perfume]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'perfume', FILENAME = N'C:\Program Files\Microsoft SQL Server\
MSSQL15.MSSQLSERVER\MSSQL\Backup\perfume.mdf' , SIZE = 8192KB , MAXSIZE =
UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
( NAME = N'perfume_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\
MSSQL15.MSSQLSERVER\MSSQL\Backup\perfume_log.ldf' , SIZE = 8192KB , MAXSIZE =
2048GB , FILEGROWTH = 65536KB )
WITH CATALOG_COLLATION = DATABASE_DEFAULT
GO
ALTER DATABASE [perfume] SET COMPATIBILITY_LEVEL = 150
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [perfume].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [perfume] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [perfume] SET ANSI_NULLS OFF
GO
ALTER DATABASE [perfume] SET ANSI_PADDING OFF
GO
ALTER DATABASE [perfume] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [perfume] SET ARITHABORT OFF
GO
ALTER DATABASE [perfume] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [perfume] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [perfume] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [perfume] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [perfume] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [perfume] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [perfume] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [perfume] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [perfume] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [perfume] SET DISABLE_BROKER
GO
ALTER DATABASE [perfume] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [perfume] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [perfume] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [perfume] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [perfume] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [perfume] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [perfume] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [perfume] SET RECOVERY FULL
GO
ALTER DATABASE [perfume] SET MULTI_USER
GO
ALTER DATABASE [perfume] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [perfume] SET DB_CHAINING OFF
GO
ALTER DATABASE [perfume] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [perfume] SET TARGET_RECOVERY_TIME = 60 SECONDS
GO
ALTER DATABASE [perfume] SET DELAYED_DURABILITY = DISABLED
GO
ALTER DATABASE [perfume] SET ACCELERATED_DATABASE_RECOVERY = OFF
GO
EXEC sys.sp_db_vardecimal_storage_format N'perfume', N'ON'
GO
ALTER DATABASE [perfume] SET QUERY_STORE = OFF
GO
USE [perfume]
GO
/****** Object: Table [dbo].[company] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[company](
[comp_id] [int] NOT NULL,
[comp_Name] [nvarchar](255) NOT NULL,
[comp_Phone] [nvarchar](50) NOT NULL,
[comp_Address] [nvarchar](255) NOT NULL,
[emp_id] [int] NOT NULL,
[comp_Date] [date] NOT NULL,
CONSTRAINT [PK_company] PRIMARY KEY CLUSTERED
(
[comp_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].[item] Script Date: 2023-12-28 10:49:10 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[item](
[item_id] [int] NOT NULL,
[item_Name] [nvarchar](255) NOT NULL,
[item_Type] [nvarchar](50) NOT NULL,
[comp_id] [int] NOT NULL,
[item_Qty] [int] NOT NULL,
[item_Price] [float] NOT NULL,
[emp_id] [int] NOT NULL,
[item_Date] [date] NOT NULL,
CONSTRAINT [PK_item] PRIMARY KEY CLUSTERED
(
[item_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].[employee] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[employee](
[emp_id] [int] NOT NULL,
[emp_Name] [nvarchar](255) NOT NULL,
[emp_Phone] [nvarchar](50) NOT NULL,
[emp_Address] [nvarchar](255) NOT NULL,
[emp_Gender] [nvarchar](20) NOT NULL,
[emp_pass] [nvarchar](255) NOT NULL,
[emp_InsertName] [nvarchar](50) NOT NULL,
[emp_Date] [date] NOT NULL,
CONSTRAINT [PK_employee] PRIMARY KEY CLUSTERED
(
[emp_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: View [dbo].[viewItem] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create view [dbo].[viewItem]
as
select item_id,item_Name,item_Type,comp_name,item_Qty,item_Price,emp_name,item_Date
from item,company,employee
where item.comp_id = company.comp_id and item.emp_id=employee.emp_id
GO
/****** Object: View [dbo].[viewCompany] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create view [dbo].[viewCompany]
as
select comp_id,comp_Name,comp_Phone,comp_Address,emp_name,comp_Date
from company,employee
where company.emp_id=employee.emp_id
GO
/****** Object: Table [dbo].[Buying] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Buying](
[Buy_id] [int] NOT NULL,
[cus_id] [int] NOT NULL,
[Buy_discount] [float] NOT NULL,
[Buy_Total] [float] NOT NULL,
[emp_id] [int] NOT NULL,
[Buy_Date] [date] NOT NULL,
CONSTRAINT [PK_Buying] PRIMARY KEY CLUSTERED
(
[Buy_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].[buy_invoice] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[buy_invoice](
[invB_id] [int] NOT NULL,
[Buy_id] [int] NOT NULL,
[item_id] [int] NOT NULL,
[invB_Qty] [int] NOT NULL,
[invB_Price] [float] NOT NULL,
[invB_Total] [float] NOT NULL,
CONSTRAINT [PK_buy_invoice] PRIMARY KEY CLUSTERED
(
[invB_id] ASC,
[Buy_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: View [dbo].[viewbuy_invoice] Script Date: 2023-12-28 10:49:10
AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create view [dbo].[viewbuy_invoice]
as
SELECT invB_id,Buying.Buy_id, item_name, invB_Qty, invB_Price, invB_Total
FROM buy_invoice,Buying,item
where buy_invoice.Buy_id = Buying.Buy_id and
buy_invoice.item_id = item.item_id
GO
/****** Object: Table [dbo].[Selling] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Selling](
[sel_id] [int] NOT NULL,
[cus_id] [int] NOT NULL,
[sel_discount] [float] NOT NULL,
[sel_Total] [float] NOT NULL,
[emp_id] [int] NOT NULL,
[sel_Date] [date] NOT NULL,
CONSTRAINT [PK_Selling] PRIMARY KEY CLUSTERED
(
[sel_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].[selling_invoice] Script Date: 2023-12-28 10:49:10
AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[selling_invoice](
[invS_id] [int] NOT NULL,
[sel_id] [int] NOT NULL,
[invS_counter] [int] NOT NULL,
[item_id] [int] NOT NULL,
[invS_Qty] [int] NOT NULL,
[invS_Price] [float] NOT NULL,
[invS_Total] [float] NOT NULL,
CONSTRAINT [PK_selling_invoice] PRIMARY KEY CLUSTERED
(
[invS_id] ASC,
[sel_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: View [dbo].[viewselling_invoice] Script Date: 2023-12-28
10:49:10 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create view [dbo].[viewselling_invoice]
as
SELECT invS_id,selling_invoice.sel_id, item_name, invS_Qty, invS_Price, invS_Total
FROM selling_invoice,Selling,item
where selling_invoice.sel_id = selling.sel_id and
selling_invoice.item_id = item.item_id
GO
/****** Object: Table [dbo].[customer] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[customer](
[cus_id] [int] NOT NULL,
[cus_Name] [nvarchar](255) NOT NULL,
[cus_Phone] [nvarchar](50) NOT NULL,
[cus_Address] [nvarchar](255) NOT NULL,
[emp_id] [int] NOT NULL,
[cus_Date] [date] NOT NULL,
[Tree_name] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_customer] PRIMARY KEY CLUSTERED
(
[cus_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: View [dbo].[viewselling] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[viewselling]
AS
SELECT dbo.Selling.sel_id, dbo.customer.cus_Name, dbo.Selling.sel_discount,
dbo.Selling.sel_Total, dbo.employee.emp_Name, dbo.Selling.sel_Date
FROM dbo.Selling INNER JOIN
dbo.customer ON dbo.Selling.cus_id = dbo.customer.cus_id
INNER JOIN
dbo.employee ON dbo.Selling.emp_id = dbo.employee.emp_id
GO
/****** Object: View [dbo].[viewbuying] Script Date: 2023-12-28 10:49:10 AM
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create view [dbo].[viewbuying]
as
SELECt Buy_id, cus_Name, Buy_discount, Buy_Total, emp_name,Buy_Date
FROM Buying,customer,employee
where Buying.cus_id = customer.cus_id and Buying.emp_id = employee.emp_id

GO
ALTER TABLE [dbo].[buy_invoice] WITH CHECK ADD CONSTRAINT [FK_buy_invoice_Buying]
FOREIGN KEY([Buy_id])
REFERENCES [dbo].[Buying] ([Buy_id])
GO
ALTER TABLE [dbo].[buy_invoice] CHECK CONSTRAINT [FK_buy_invoice_Buying]
GO
ALTER TABLE [dbo].[buy_invoice] WITH CHECK ADD CONSTRAINT [FK_buy_invoice_item]
FOREIGN KEY([item_id])
REFERENCES [dbo].[item] ([item_id])
GO
ALTER TABLE [dbo].[buy_invoice] CHECK CONSTRAINT [FK_buy_invoice_item]
GO
ALTER TABLE [dbo].[Buying] WITH CHECK ADD CONSTRAINT [FK_Buying_customer] FOREIGN
KEY([cus_id])
REFERENCES [dbo].[customer] ([cus_id])
GO
ALTER TABLE [dbo].[Buying] CHECK CONSTRAINT [FK_Buying_customer]
GO
ALTER TABLE [dbo].[Buying] WITH CHECK ADD CONSTRAINT [FK_Buying_employee] FOREIGN
KEY([emp_id])
REFERENCES [dbo].[employee] ([emp_id])
GO
ALTER TABLE [dbo].[Buying] CHECK CONSTRAINT [FK_Buying_employee]
GO
ALTER TABLE [dbo].[company] WITH CHECK ADD CONSTRAINT [FK_company_employee]
FOREIGN KEY([emp_id])
REFERENCES [dbo].[employee] ([emp_id])
GO
ALTER TABLE [dbo].[company] CHECK CONSTRAINT [FK_company_employee]
GO
ALTER TABLE [dbo].[customer] WITH CHECK ADD CONSTRAINT [FK_customer_employee]
FOREIGN KEY([emp_id])
REFERENCES [dbo].[employee] ([emp_id])
GO
ALTER TABLE [dbo].[customer] CHECK CONSTRAINT [FK_customer_employee]
GO
ALTER TABLE [dbo].[item] WITH CHECK ADD CONSTRAINT [FK_item_company] FOREIGN
KEY([comp_id])
REFERENCES [dbo].[company] ([comp_id])
GO
ALTER TABLE [dbo].[item] CHECK CONSTRAINT [FK_item_company]
GO
ALTER TABLE [dbo].[item] WITH CHECK ADD CONSTRAINT [FK_item_employee] FOREIGN
KEY([emp_id])
REFERENCES [dbo].[employee] ([emp_id])
GO
ALTER TABLE [dbo].[item] CHECK CONSTRAINT [FK_item_employee]
GO
ALTER TABLE [dbo].[Selling] WITH CHECK ADD CONSTRAINT [FK_Selling_customer]
FOREIGN KEY([cus_id])
REFERENCES [dbo].[customer] ([cus_id])
GO
ALTER TABLE [dbo].[Selling] CHECK CONSTRAINT [FK_Selling_customer]
GO
ALTER TABLE [dbo].[Selling] WITH CHECK ADD CONSTRAINT [FK_Selling_employee]
FOREIGN KEY([emp_id])
REFERENCES [dbo].[employee] ([emp_id])
GO
ALTER TABLE [dbo].[Selling] CHECK CONSTRAINT [FK_Selling_employee]
GO
ALTER TABLE [dbo].[selling_invoice] WITH CHECK ADD CONSTRAINT
[FK_selling_invoice_item] FOREIGN KEY([item_id])
REFERENCES [dbo].[item] ([item_id])
GO
ALTER TABLE [dbo].[selling_invoice] CHECK CONSTRAINT [FK_selling_invoice_item]
GO
ALTER TABLE [dbo].[selling_invoice] WITH CHECK ADD CONSTRAINT
[FK_selling_invoice_Selling] FOREIGN KEY([sel_id])
REFERENCES [dbo].[Selling] ([sel_id])
GO
ALTER TABLE [dbo].[selling_invoice] CHECK CONSTRAINT [FK_selling_invoice_Selling]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-
11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1 [50] 2 [25] 3))"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1[56] 4[18] 2) )"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "Selling"
Begin Extent =
Top = 6
Left = 38
Bottom = 136
Right = 208
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "customer"
Begin Extent =
Top = 6
Left = 246
Bottom = 136
Right = 416
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "employee"
Begin Extent =
Top = 138
Left = 38
Bottom = 268
Right = 217
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'VIEW',@level1name=N'viewselling'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'VIEW',@level1name=N'viewselling'
GO
USE [master]
GO
ALTER DATABASE [perfume] SET READ_WRITE
GO

You might also like