简体   繁体   English

数据库表设计任务

[英]Database table design task

There is a factory with 15 production lines. 有一个拥有15条生产线的工厂。 Each production line, every day gets its own table and needs to fill in efficiency measurements every hour. 每条生产线每天都有自己的表格,需要每小时填写一次效率度量。 Table consists of columns (time periods) and categories with sub categories which makes it around 80 rows. 表由列(时间段)和带有子类别的类别组成,这使它大约有80行。 Here is an example: 这是一个例子:

http://postimg.org/image/rhfmnv0jr/

Could you give me any suggestions with database design ? 您能给我有关数据库设计的任何建议吗?

Requirements: 要求:

Server needs to get all table data for specific day fast. 服务器需要快速获取特定日期的所有表数据。 Server needs to retrieve a specific cell (by line number, date, time period and subcategory) fast. 服务器需要快速检索特定的单元格(按行号,日期,时间段和子类别)。

create table metric
(   -- a thing to track
    metricNum int auto_increment primary key, -- 1,2,3 etc
    metricName varchar(200) -- ie: "Splat & spild", etc
);


create table efficiency
(   -- all data for all lines for all time
    id int auto_increment primary key,
    lineNum int not null,
    theDate day not null,
    metricNum int not null,
    theHour int not null,
    theCount int not null
    -- add indexes of use
    -- add foreign key (FK) constraint(s), such as to metric
);

That's it. 而已。 Two tables. 两张桌子。 Not each line with a new table each day. 并非每一行每天都有一个新表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM