防性能主细节查询

时间:2019-03-31 17:28:34

标签: php mysql performance

说我有两个表:

Master(id,name,otherproperties);
Detail(id,masterid,name,otherproperties);

在单个查询中选择master及其详细信息并在php中建立对象的最佳方法是什么:

$master = array(
    "id" = query result,
    "name" = query result,
    "details" = query result
);

在我的情况下,这是我的表定义:

create table supplement_groups(
    supplementgroupid bigint not null auto_increment,
    name varchar(50) not null,
    vendorid bigint not null, //don't mind this
    primary key (supplementgroupid),
    foreign key (vendorid) references vendor(vendorid)
);

create table supplement(
    supplementid bigint not null auto_increment,
    name varchar(50) not null,
    price decimal(18,2) not null,
    supplementgroupid bigint not null,
    deleted boolean not null default false,
    primary key (supplementid),
    foreign key (supplementgroupid) references supplement_groups(supplementgroupid)
);

0 个答案:

没有答案