1、识别(实体)
2、识别E-R图
3、数据表的建立
根据E-R图的结构和功能关系完成数据表
数据库.PNG
4、生成数据库表
在构思好数据表后接下来就按照数据表的结构和功能关系生成相关的考勤数据库。
USE [kaoqin]
GO
/****** Object: Table [dbo].[recrd table] Script Date: 07/02/2018 19:52:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[recrd table](
[senal] [varchar](50) NOT NULL,
[date] [date] NULL,
[time] [time](0) NULL,
[employ_id] [varchar](50) NULL,
[machine_id] [varchar](50) NULL,
CONSTRAINT [PK_recrd table] PRIMARY KEY CLUSTERED
(
[senal] 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
/****** Object: Table [dbo].[Punch machine] Script Date: 07/02/2018 19:52:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Punch machine](
[machine_id] [nchar](10) NOT NULL,
[name] [nchar](10) NOT NULL,
[time] [nchar](10) NOT NULL,
[local] [nchar](10) NOT NULL,
CONSTRAINT [PK_Punch machine] PRIMARY KEY CLUSTERED
(
[machine_id] 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
/****** Object: Table [dbo].[clerk table] Script Date: 07/02/2018 19:52:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[clerk table](
[id] [nchar](10) NOT NULL,
[name] [nchar](10) NOT NULL,
[sex] [nchar](10) NULL,
[age] [nchar](10) NULL,
[parte] [nchar](10) NULL,
[lemite] [nchar](10) NULL,
CONSTRAINT [PK_clerk table] PRIMARY KEY CLUSTERED
(
[id] 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
/****** Object: ForeignKey [FK_recrd table_recrd table] Script Date: 07/02/2018 19:52:08 ******/
ALTER TABLE [dbo].[recrd table] WITH CHECK ADD CONSTRAINT [FK_recrd table_recrd table] FOREIGN KEY([senal])
REFERENCES [dbo].[recrd table] ([senal])
GO
ALTER TABLE [dbo].[recrd table] CHECK CONSTRAINT [FK_recrd table_recrd table]
GO
网友评论