drop database if exists ShoppingWebsite;
create database if not exists ShoppingWebsite;
use ShoppingWebsite;

/*  node stuctor
    userAccount
    +   cart
        +   user_cart[]
    +   collect
        +   user_collect[]
*/
create table if not exists userAccount
(
    email varchar(50) not null primary key,
    password varchar(16) not null,
    permission_id bigint
);

create table if not exists user_cart
(
    user_email varchar(50) not null,
    addin_time datetime not null,
    mun int not null
);

create table if not exists user_collect
(
    user_email varchar(50) not null,
    addin_time datetime not null,
    goodId bigint not null
);



/*  node stuctor
    store
    +   goods[]
        +   selections
            +   selectionGroup[]
                +   selection[]
        +   comments
            +   comment[]
*/
create table if not exists store
(
    store_Id bigint not null primary key,
    postion varchar(100) not null,
    store_name varchar(50) not null,
    star int
);

create table if not exists goods
(
    goods_Id bigint not null primary key,
    store_Id bigint not null,
    postion varchar(100) not null,
    goods_name varchar(50) not null,
    star int
);

create table if not exists selection_group
(
    selection_group_Id bigint not null primary key,
    goods_Id bigint not null,
    selection_group_name varchar(50) not null
);

create table if not exists selection
(
    selection_Id bigint not null primary key,
    selection_group_Id bigint not null,
    selection_name varchar(50) not null,
    price float(13,2) not null
);

create table if not exists comment
(
    selection_Id bigint not null,
    user_email varchar(50) not null,
    comment_time datetime not null,
    comment_text text not null
);