数据库设计

1.识别实体

①打卡机
②员工

2.E-R图
E-R图.jpg
3.数据表
员工
PK 工号
姓名
年龄
职位
部门
打卡机
PK 编号
位置
合并后生成的新表:
打卡
PK ID
FK1 工号
日期
FK2 编号
时间
4.数据库表
CREATE TABLE [dbo].[dakaji](
    [number] [varchar](50) NOT NULL,
    [location] [varchar](50) NULL,
 CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED 
(
    [number] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[daka information](
    [ID] [varchar](50) NOT NULL,
    [job number] [varchar](50) NULL,
    [date] [varchar](50) NULL,
    [number] [varchar](50) NULL,
    [time] [time](7) NULL,
 CONSTRAINT [PK_Table_2] 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]
CREATE TABLE [dbo].[employer](
    [job number] [nchar](10) NOT NULL,
    [name] [nchar](10) NULL,
    [age] [nchar](10) NULL,
    [position] [nchar](10) NULL,
    [department] [nchar](10) NULL,
 CONSTRAINT [PK_Table_3] PRIMARY KEY CLUSTERED 
(
    [job number] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

你可能感兴趣的:(数据库设计)