发表于: 2017-12-02 19:25:49

1 684


今天完成的任务:

职业方向 表字段设计

table career_types 
id (int) 
name(varcha) 
create_at 
update_at


报名表 字段设计


id int name (varchar) 
QQ (varchar) 
career_type (refer id) 
start_datetime (time) 
school(varchar) 
online_id(int) 
report_url(varchar) 
brother_name(varchar) 
create_at 
update_at


因为对数据库类型字段并不是很有把握,所以先写了大概的字段设计, 具体建表的时候,根据数据库类型再去查手册,照猫画虎如下

create table career_types  

(     

id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,    

name varchar(128),     

create_at BIGINT default now(),     

update_at BIGINT default now()

);

create table students  (  

id BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,  

name varchar(64) NOT NULL,

QQ varchar,

career_type bigint,  

start_time datetime,  

school varchar(128),  

online_id varchar(128) NOT NULL,  

report_url varchar(128),  

brother_name varchar(64),  

create_at bigint DEFAULT now(),  

update_at bigint DEFAULT now() ,   

FOREIGN KEY (career_type) REFERENCES career_types (id)  ON DELETE CASCADE

);


插入语句

INSERT INTO career_types (name) values ( '前端工程师'),('JAVA工程师'),('运维工程师'),('iOS工程师'),('Android工程师'),('UI设计师'),('产品经理');


MariaDB [xiuzhen]> select * from career_types;

+----+------------------+----------------+----------------+

| id | name             | create_at      | update_at      |

+----+------------------+----------------+----------------+

|  1 | 前端工程师       | 20171202190859 | 20171202190859 |

|  2 | JAVA工程师       | 20171202190859 | 20171202190859 |

|  3 | 运维工程师       | 20171202190859 | 20171202190859 |

|  4 | iOS工程师        | 20171202190859 | 20171202190859 |

|  5 | Android工程师    | 20171202190859 | 20171202190859 |

|  6 | UI设计师         | 20171202190859 | 20171202190859 |

|  7 | 产品经理         | 20171202190859 | 20171202190859 |

+----+------------------+----------------+----------------+


插入一个学生

insert into students (name, QQ, career_type, start_time, school, online_id, report_url, brother_name) value ('李浩','1162553773', 1, '2017-10-25 18:30:23', '辽宁石油能源学院','css-4585', "http::/mianjin.com/xxx.oo.html", 'JS-刘夏洋');


查询结果 

MariaDB [xiuzhen]> select * from students where id=1 \G;

*************************** 1. row ***************************

          id: 1

        name: 李浩

 career_type: 1

    datetime: 2017-10-25

      school: 辽宁石油能源学院

   online_id: css-4585

  report_url: http::/mianjin.com/xxx.oo.html

brother_name: JS-刘夏洋

   create_at: 20171202191545

   update_at: 20171202191545

          QQ: 1162553773

1 row in set (0.00 sec)

使用姓名直接查询也是没有问题的

不过忘记了说狠话字段 修改表结构加之 

MariaDB [xiuzhen]> alter table students add column desire varchar(128);

update students set desire='老大最帅';

明天任务: 继续搞剩下的任务



返回列表 返回列表
评论

    分享到