常用数据库表设计

365次阅读
没有评论

//

常用的数据库表设计,后续陆续添加吧,代码是laravel的migration。懒得换成sql了。

一,用户表

//start
Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name')->nullable();
            $table->string('nickname')->nullable();
            $table->string('avatar')->nullable()->comment('头像');
            $table->string('email')->nullable();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('phone')->nullable();
            $table->timestamp('phone_verified_at')->nullable();
            $table->string('password');
            $table->tinyInteger('vip')->default(0)->nullable()->comment('vip登记,0为不是vip,然后123');
            $table->timestamp('vip_time')->nullable()->comment('会员到期时间');
            $table->tinyInteger('fenxiao')->default(1)->nullable()->comment('分销等级,默认1,系统应该设置最高分销等级,一般默认3');
            $table->string('price')->default(0)->nullable()->comment('余额');
            $table->string('integral')->default(0)->nullable()->comment('积分');
            $table->tinyInteger('state')->default(0)->comment('0未审核,1已审核');
            $table->tinyInteger('is_admin')->default('0')->comment('0不是后台,1后台人员');
            $table->string('register_ip')->default('')->comment('注册ip');
            $table->string('last_ip')->default('')->comment('上次登陆ip');
            $table->rememberToken();
            $table->timestamps();
        });
//over

二,栏目表

//
Schema::create('category', function (Blueprint $table) {
            $table->id();
            $table->string('title')->comment('栏目标题');
            $table->string('ftitle')->nullable()->comment('栏目副标题');
            $table->text('info')->nullable()->comment('栏目简介');
            $table->mediumText('content')->nullable()->comment('content');
            $table->string('thumb')->nullable()->comment('缩略图');
            $table->string('banner')->nullable()->comment('栏目banner');
            $table->integer('parent_id')->comment('上级栏目');
            $table->tinyInteger('sort')->nullable()->comment('排序');
            $table->string('state')->default('on')->nullable()->comment('状态,off关闭,on正常');
            $table->string('type')->nullable()->comment('栏目类型,case,article,page,img,imgs,');
            $table->string('seotitle')->nullable()->comment('seo title');
            $table->string('keywords')->nullable()->comment('keywords');
            $table->string('description')->nullable()->comment('description');
            $table->string('view')->nullable()->comment('模板文件名');
            $table->string('external_links')->nullable()->comment('外部链接');
            $table->softDeletes(); //软删除
            $table->timestamps();
        });
//

三,文章表

//
Schema::create('article', function (Blueprint $table) {
            $table->id();
            $table->string('title')->comment('文章标题');
            $table->string('ftitle')->nullable()->comment('文章副标题');
            $table->string('thumb','500')->nullable()->comment('缩略图');
            $table->string('imgs','3000')->nullable()->comment('图集');
            $table->integer('category_id')->nullable()->comment('所属栏目');
            $table->integer('user_id')->nullable()->comment('用户id');
            $table->text('info')->nullable()->comment('简介');
            $table->mediumText('content')->nullable()->comment('content');
            $table->string('state')->default('on')->nullable()->comment('状态,off关闭,on正常');
            $table->string('is_comment')->default('on')->nullable()->comment('off-不允许,on-允许评论');
            $table->tinyInteger('sort')->default(100)->nullable()->comment('排序');
            $table->tinyInteger('tuijian')->default(0)->nullable()->comment('推荐');
            $table->tinyInteger('toutiao')->default(0)->nullable()->comment('头条');
            $table->string('seotitle')->nullable()->comment('seo title');
            $table->string('keywords')->nullable()->comment('keywords');
            $table->string('description')->nullable()->comment('description');
            $table->softDeletes(); //软删除
            $table->timestamps();
        });
//

四,tag表

//
Schema::create('tag', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('slug')->nullable();
            $table->string('keywords',500)->nullable();
            $table->string('description',500)->nullable();
            $table->string('state')->default('on')->nullable()->comment('状态,off关闭,on正常');
            $table->timestamps();
        });

 Schema::create('article_tag', function (Blueprint $table) {
            $table->id();
            $table->integer('tag_id');
            $table->integer('article_id');
            $table->timestamps();
        });
//

五,评论表

//
Schema::create('commont', function (Blueprint $table) {
            $table->id();
            $table->tinyInteger('user_id')->comment('会员id');
            $table->tinyInteger('article_id')->nullable()->comment('文章id');
            $table->tinyInteger('good_id')->nullable()->comment('商品id');
            $table->string('parent_id')->nullable()->default(0)->comment('回复谁的');
            $table->string('content',1000)->comment('回复的主体内容');
            $table->string('re_mark',1000)->nullable()->comment('管理员回复的内容');
            $table->string('state')->default('on')->nullable()->comment('状态,off关闭,on正常');
            $table->softDeletes(); //软删除
            $table->timestamps();
        });
//

六,友情链接

//
Schema::create('link', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('url','500')->nullable();
            $table->tinyInteger('sort')->nullable();
            $table->tinyInteger('type')->nullable()->comment('链接分类,0都显示,1文字,2图片,');
            $table->string('logo','500')->nullable()->comment('网站标志');
            $table->string('state')->default('on')->nullable()->comment('状态,off关闭,on正常');
            $table->dateTime('overtime')->nullable()->comment('过期时间');
            $table->timestamps();
        });
//

七,网站site表

//
Schema::create('site', function (Blueprint $table) {
            $table->id();
            $table->string('key_name');
            $table->string('value',1000);
            $table->timestamps();
        });
//

八,文件表

//
Schema::create('files', function (Blueprint $table) {
            $table->id();
            $table->string('state')->default('on')->nullable()->comment('状态,off关闭,on正常');
            $table->string('location',500)->nullable()->comment('文件位置');
            $table->string('type')->nullable()->comment('文件类型,img图片,');
            $table->timestamps();
        });
//

九,后台栏目表

//
Schema::create('admin_menus', function (Blueprint $table) {
            $table->id();
            $table->string('name')->comment('后台栏目,中文名称');
            $table->string('css')->nullable()->comment('本栏目样式');
            $table->string('url')->nullable()->comment('连接地址,也可以是外链,如果有,就用url,如果米有,就用route');
            $table->string('route')->nullable()->comment('route名,也是permission的名称,添加一个栏目,就需要laravel-permission也添加一个permission。');
            $table->integer('parent_id')->comment('上级栏目');
            $table->string('info')->nullable()->comment('简介');
            $table->integer('sort')->nullable()->comment('排序');
            $table->string('state')->nullable()->comment('on,off,null');
            $table->string('pinlei')->nullable()->comment('相同品类的栏目,如果相同,上级栏目展开,如果不是顶级栏目,品类自动跟随上级栏目');
            $table->timestamps();
        });
//

 

 

 

 

 

 

 

 

 

 

李路昌
版权声明:本站原创文章,由 李路昌 2022-10-17发表,共计5875字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)