Tải bản đầy đủ (.docx) (5 trang)

FILE KỊCH BẢN – TẠO CSDL QLY_SINHVIEN

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (47.04 KB, 5 trang )

(1)

USE [QL_DIEMTHISV]
GO


/****** Object: Table [dbo].[DMKHOA] Script Date: 08/21/2014
08:50:34 ******/


SET ANSI_NULLS ON
GO


SET QUOTED_IDENTIFIER ON
GO


CREATE TABLE [dbo].[DMKHOA](


[MAKHOA] [nchar](10) NOT NULL,
[TENKHOA] [nvarchar](30) NULL,
[DIENTHOAI] [nvarchar](13) NULL,
CONSTRAINT [PK_SV] PRIMARY KEY CLUSTERED
(


[MAKHOA] ASC


)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


) ON [PRIMARY]
GO


INSERT [dbo].[DMKHOA] ([MAKHOA], [TENKHOA], [DIENTHOAI]) VALUES (N'CNTT
', N'Công nghệ thông tin', NULL)



INSERT [dbo].[DMKHOA] ([MAKHOA], [TENKHOA], [DIENTHOAI]) VALUES (N'TH
', N'Tiểu học ', N'0567890565')


INSERT [dbo].[DMKHOA] ([MAKHOA], [TENKHOA], [DIENTHOAI]) VALUES (N'TN
', N'Tự nhiên ', NULL)


/****** Object: Table [dbo].[DIEMTHI] Script Date: 08/21/2014
08:50:34 ******/


SET ANSI_NULLS ON
GO


SET QUOTED_IDENTIFIER ON
GO


SET ANSI_PADDING ON
GO


CREATE TABLE [dbo].[DIEMTHI](


[MAMONHOC] [varchar](10) NOT NULL,
[MASV] [varchar](10) NOT NULL,
[DIEMMH] [numeric](4, 2) NULL,
[HOCKY] [char](3) NULL,


CONSTRAINT [pk_diemthi] PRIMARY KEY CLUSTERED
(


[MAMONHOC] ASC,
[MASV] ASC



)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


) ON [PRIMARY]
GO


SET ANSI_PADDING OFF
GO


INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'001', N'001', CAST(2.00 AS Numeric(4, 2)), N'I ')


INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'001', N'002', CAST(2.00 AS Numeric(4, 2)), N'I ')


INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'002', N'001', CAST(5.00 AS Numeric(4, 2)), N'I ')



(2)

INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'003', N'001', CAST(8.00 AS Numeric(4, 2)), N'I ')


INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'003', N'002', CAST(7.00 AS Numeric(4, 2)), N'I ')


INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'4', N'001', CAST(2.00 AS Numeric(4, 2)), N'II ')


INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'4', N'002', CAST(2.00 AS Numeric(4, 2)), N'II ')



INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'5', N'001', CAST(5.00 AS Numeric(4, 2)), N'II ')


INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'5', N'002', CAST(4.00 AS Numeric(4, 2)), N'II ')


INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'6', N'001', CAST(8.00 AS Numeric(4, 2)), N'II ')


INSERT [dbo].[DIEMTHI] ([MAMONHOC], [MASV], [DIEMMH], [HOCKY]) VALUES
(N'6', N'002', CAST(7.00 AS Numeric(4, 2)), N'II ')


/****** Object: Table [dbo].[DIEMTBC] Script Date: 08/21/2014
08:50:34 ******/


SET ANSI_NULLS ON
GO


SET QUOTED_IDENTIFIER ON
GO


SET ANSI_PADDING ON
GO


CREATE TABLE [dbo].[DIEMTBC](


[MaSV] [varchar](10) NOT NULL,
[HOCKY] [char](3) NULL,



[DTBC] [numeric](38, 6) NULL,
[Xeploai] [nvarchar](10) NULL
) ON [PRIMARY]


GO


SET ANSI_PADDING OFF
GO


INSERT [dbo].[DIEMTBC] ([MaSV], [HOCKY], [DTBC], [Xeploai]) VALUES
(N'001', N'I ', CAST(5.000000 AS Numeric(38, 6)), N'Y?u')


INSERT [dbo].[DIEMTBC] ([MaSV], [HOCKY], [DTBC], [Xeploai]) VALUES
(N'002', N'I ', CAST(4.363636 AS Numeric(38, 6)), N'Y?u')


INSERT [dbo].[DIEMTBC] ([MaSV], [HOCKY], [DTBC], [Xeploai]) VALUES
(N'001', N'II ', CAST(4.700000 AS Numeric(38, 6)), N'Y?u')


INSERT [dbo].[DIEMTBC] ([MaSV], [HOCKY], [DTBC], [Xeploai]) VALUES
(N'002', N'II ', CAST(4.100000 AS Numeric(38, 6)), N'Y?u')


/****** Object: Table [dbo].[SINHVIEN] Script Date: 08/21/2014
08:50:34 ******/


SET ANSI_NULLS ON
GO


SET QUOTED_IDENTIFIER ON
GO



SET ANSI_PADDING ON
GO


CREATE TABLE [dbo].[SINHVIEN](


[hs_ID] [int] IDENTITY(1,1) NOT NULL,
[MaSV] [varchar](10) NOT NULL,



(3)

[Gioitinh] [bit] NULL,


CONSTRAINT [KP_MASV] PRIMARY KEY CLUSTERED
(


[MaSV] ASC


)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


) ON [PRIMARY]
GO


SET ANSI_PADDING OFF
GO


SET IDENTITY_INSERT [dbo].[SINHVIEN] ON


INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],
[DiaChi], [Dienthoai], [Gioitinh]) VALUES (8, N'CT11 10', N'CT11 ',
N'Phan Thanh Huy', CAST(0x8CCD0000 AS SmallDateTime), N'PM', NULL, 1)
INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],


[DiaChi], [Dienthoai], [Gioitinh]) VALUES (9, N'CT11 11', N'CT11 ',
N'Hồ Thúy Hằng', CAST(0x8CCD0000 AS SmallDateTime), N'PC', NULL, 0)
INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],
[DiaChi], [Dienthoai], [Gioitinh]) VALUES (1, N'CT11 6', N'CT11 ',
N'Trần Thị Hoa', CAST(0x8B600000 AS SmallDateTime), N'QN', NULL, 0)
INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],
[DiaChi], [Dienthoai], [Gioitinh]) VALUES (2, N'CT11 7', N'CT11 ',
N'Phan Thanh Hoa', CAST(0x8CCD0000 AS SmallDateTime), N'QN', NULL, 0)
INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],
[DiaChi], [Dienthoai], [Gioitinh]) VALUES (4, N'CT11 8', N'CT11 ',
N'Trần Thanh Huy', CAST(0x7D1B0000 AS SmallDateTime), N'TS', NULL, 1)
INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],
[DiaChi], [Dienthoai], [Gioitinh]) VALUES (6, N'CT11 9', N'CT11 ',
N'Hồ Thanh Thủy', CAST(0x8CCD0000 AS SmallDateTime), N'TS', NULL, 0)
INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],
[DiaChi], [Dienthoai], [Gioitinh]) VALUES (10, N'CT12 12', N'CT12
', N'Phan ThanhThuyr', CAST(0x8CCD0000 AS SmallDateTime), N'PC', NULL,
1)


INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],
[DiaChi], [Dienthoai], [Gioitinh]) VALUES (11, N'CT12 13', N'CT12
', N'Phan Thành Nhân', CAST(0x8CAE0000 AS SmallDateTime), N'PC', NULL,
1)


INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],
[DiaChi], [Dienthoai], [Gioitinh]) VALUES (12, N'CT12 14', N'CT12
', N'Phan Huy', CAST(0x8CCD0000 AS SmallDateTime), N'DC', NULL, 1)


INSERT [dbo].[SINHVIEN] ([hs_ID], [MaSV], [MaLop], [HoTen], [NgaySinh],
[DiaChi], [Dienthoai], [Gioitinh]) VALUES (16, N'CT12 15', N'CT12


', N'Tào', CAST(0x8CCD0000 AS SmallDateTime), N'DC', NULL, 1)



(4)

/****** Object: Table [dbo].[DMMON] Script Date: 08/21/2014 08:50:34
******/


SET ANSI_NULLS ON
GO


SET QUOTED_IDENTIFIER ON
GO


SET ANSI_PADDING ON
GO


CREATE TABLE [dbo].[DMMON](


[MAMON] [varchar](10) NOT NULL,
[TENMON] [nvarchar](50) NOT NULL,
[SODVHT] [tinyint] NULL,


CONSTRAINT [pk_dmmon] PRIMARY KEY CLUSTERED
(


[MAMON] ASC


)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


) ON [PRIMARY]
GO



SET ANSI_PADDING OFF
GO


INSERT [dbo].[DMMON] ([MAMON], [TENMON], [SODVHT]) VALUES (N'001
', N'Access', 4)


INSERT [dbo].[DMMON] ([MAMON], [TENMON], [SODVHT]) VALUES (N'002
', N'Pascal', 3)


INSERT [dbo].[DMMON] ([MAMON], [TENMON], [SODVHT]) VALUES (N'003
', N'Tin học Văn phòng', 4)


INSERT [dbo].[DMMON] ([MAMON], [TENMON], [SODVHT]) VALUES (N'004
', N'Tiếng Anh', 3)


INSERT [dbo].[DMMON] ([MAMON], [TENMON], [SODVHT]) VALUES (N'4
', N'SQL', 4)


INSERT [dbo].[DMMON] ([MAMON], [TENMON], [SODVHT]) VALUES (N'5
', N'PTTK', 3)


INSERT [dbo].[DMMON] ([MAMON], [TENMON], [SODVHT]) VALUES (N'6
', N'Mạng Máy tính', 3)


/****** Object: Table [dbo].[DMLOP] Script Date: 08/21/2014 08:50:34
******/


SET ANSI_NULLS ON
GO



SET QUOTED_IDENTIFIER ON
GO


SET ANSI_PADDING ON
GO


CREATE TABLE [dbo].[DMLOP](


[MALOP] [varchar](10) NOT NULL,
[TENLOP] [nvarchar](30) NULL,
[MAKHOA] [nchar](10) NOT NULL,
[KHOAHOC] [smallint] NULL,
[HEDT] [nvarchar](20) NULL,
[NAMNHAPHOC] [nchar](4) NULL,


CONSTRAINT [pk_dmlop] PRIMARY KEY CLUSTERED
(


[MALOP] ASC


)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]



(5)

SET ANSI_PADDING OFF
GO


INSERT [dbo].[DMLOP] ([MALOP], [TENLOP], [MAKHOA], [KHOAHOC], [HEDT],
[NAMNHAPHOC]) VALUES (N'CT11 ', N'Cao đẳng tin học', N'CNTT ',
11, N'CĐ', N'2012')



INSERT [dbo].[DMLOP] ([MALOP], [TENLOP], [MAKHOA], [KHOAHOC], [HEDT],
[NAMNHAPHOC]) VALUES (N'CT12 ', N'Cao đẳng tin học', N'CNTT ',
12, N'CĐ', N'2013')


INSERT [dbo].[DMLOP] ([MALOP], [TENLOP], [MAKHOA], [KHOAHOC], [HEDT],
[NAMNHAPHOC]) VALUES (N'CT13 ', N'cao đẳng tin học ', N'CNTT
', 13, N'CĐ', N'2014')


/****** Object: Default [DF_DMLOP_MAKHOA] Script Date: 08/21/2014
08:50:34 ******/


ALTER TABLE [dbo].[DMLOP] ADD CONSTRAINT [DF_DMLOP_MAKHOA] DEFAULT
(N'SP') FOR [MAKHOA]


GO


/****** Object: Default [DF_DMMON_SODVHT] Script Date: 08/21/2014
08:50:34 ******/


ALTER TABLE [dbo].[DMMON] ADD CONSTRAINT [DF_DMMON_SODVHT] DEFAULT
((3)) FOR [SODVHT]


GO


/****** Object: Check [CK_DMLOP] Script Date: 08/21/2014 08:50:34
******/


ALTER TABLE [dbo].[DMLOP] WITH CHECK ADD CONSTRAINT [CK_DMLOP] CHECK
(([HEDT]=N'ĐH' OR [HEDT]=N'CĐ'))



GO


ALTER TABLE [dbo].[DMLOP] CHECK CONSTRAINT [CK_DMLOP]
GO


/****** Object: Check [CK_DMMON] Script Date: 08/21/2014 08:50:34
******/


ALTER TABLE [dbo].[DMMON] WITH CHECK ADD CONSTRAINT [CK_DMMON] CHECK
(([SODVHT]<=(6)))


GO


ALTER TABLE [dbo].[DMMON] CHECK CONSTRAINT [CK_DMMON]
GO


/****** Object: Check [chk_nhanvien_dienthoai] Script Date:
08/21/2014 08:50:34 ******/


ALTER TABLE [dbo].[SINHVIEN] WITH CHECK ADD CONSTRAINT


[chk_nhanvien_dienthoai] CHECK (([Dienthoai] like '[0-9][0-9][0-9][0-9]
[0-9][0-9][0-9]'))


GO


ALTER TABLE [dbo].[SINHVIEN] CHECK CONSTRAINT [chk_nhanvien_dienthoai]
GO



/****** Object: ForeignKey [FK_DMLOP_DMKHOA] Script Date: 08/21/2014
08:50:34 ******/


ALTER TABLE [dbo].[DMLOP] WITH CHECK ADD CONSTRAINT [FK_DMLOP_DMKHOA]
FOREIGN KEY([MAKHOA])


REFERENCES [dbo].[DMKHOA] ([MAKHOA])
GO





×