简体   繁体   中英

Database table design task

There is a factory with 15 production lines. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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