You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

餐厅数据库函数依赖推导、BCNF表规范化及构建技术求助

餐厅管理数据库作业需求

我已完成餐厅ER图制作,作为个人作业,希望获得函数依赖推导、表规范化(BCNF范式)以及基于所得关系构建数据库的相关协助。

更新:
我已搭建关系模型并将其规范化至3NF。

已编写的Oracle SQL代码

create table restaurant(
    name varchar(20),
    city varchar(20) not null,
    contact_no char(15),
    constraint pk_name_restaurant primary key(name)
    );

create table contact_number(
    contact_no char(15),
    address varchar(50) not null,
    constraint pk_contact_no_contact_number primary key(contact_no)
    
);
create table cashier(
    cashier_id char(10)  ,
    cashier_name varchar(20) not null,
    constraint pk_chashierId_cashier primary key(cashier_id)

);

create table restaurant_has(
    name varchar(20),
    cashier_id char(10),
    constraint pk_restaurantHas primary key(name,cashier_id)
 
);

create table chef(
    chef_id char(10),
    chef_name varchar(20) not null,
    salary number(5,0),
    constraint pk_chefid_chef primary key(chef_id)
);

create table chef_works(
    name varchar(20) ,
    chef_id char(10),
    constraint pk_chefworks primary key(name,chef_id)
);


create table customer_order(
    order_no char(10),
    num_meals number(2,0),
    bill_no char(10) not null,
    constraint pk_orderno_order primary key(order_no)
);

create table chef_prepares(
    chef_id char(10),
    order_no char(10),
    constraint pk_chefprepares primary key(chef_id,order_no)
);

create table meal(
    meal_no char(10),
    quantity number(2,0),
    meal_price number(2,0),
    meal_title varchar(25) not null,
    order_no char(10) not null,
    constraint pk_orderno_meal primary key(meal_no)
);

create table meal_title(
    meal_title varchar(25),
    ingredients varchar(75) not null,
    constraint pk_mealtitle primary key(meal_title)
);

create table customer(
    cust_id char(10),
    cust_address varchar(50),
    cust_phone char(15) not null,
    constraint pk_custid_customer primary key(cust_id)
);

create table customer_phone(
    cust_phone char(15),
    cust_name varchar(20) not null,
    constraint pk_customerphone primary key(cust_phone) 
);

create table order_bill(
    bill_no char(10),
    price number(5,0) not null,
    bill_date date not null,
    cust_id char(10) not null,
    cashier_id char(10) not null,
    constraint pk_billno_orderbill primary key(bill_no)
);

alter table restaurant add constraint fk_contactNo_restaurant foreign key(contact_no) references contact_number(contact_no);

alter table restaurant_has add constraint fk_name_restauranthas foreign key(name) references restaurant(name);

alter table restaurant_has add constraint fk_cashierid_restauranthas foreign key(cashier_id) references cashier(cashier_id);

alter table chef_works add constraint fk_name_chefworks foreign key(name) references restaurant(name);

alter table chef_works add constraint fk_chefid_chefworks foreign key(chef_id) references chef(chef_id);

alter table chef_prepares add constraint fk_chefid_chefprepares foreign key(chef_id) references chef(chef_id);

alter table chef_prepares add constraint fk_orderno_chefprepares foreign key(order_no) references customer_order(order_no);

alter table customer_order add constraint fk_billno_customerorder foreign key(bill_no) references  order_bill(bill_no);

alter table meal add constraint fk_mealtitle_meal foreign key(meal_title) references meal_title(meal_title);

alter table meal add constraint fk_orderno_meal foreign key(order_no) references customer_order(order_no);

alter table customer add constraint fk_custphone_customer foreign key(cust_phone) references customer_phone(cust_phone);

alter table order_bill add constraint fk_custid_orderbill foreign key(cust_id) references customer(cust_id);

alter table order_bill add constraint fk_cashierid_orderbill foreign key(cashier_id) references cashier(cashier_id);

内容的提问来源于stack exchange,提问作者NailaBagir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.20 07:06:04