企业新闻管理系统数据库建设

Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.13-enterprise-commercial-advanced MySQL Enterprise Server -
Advanced Edition (Commercial)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database webnews;
Query OK, 1 row affected (0.01 sec)
mysql> use webnews;
Database changed
mysql> create table Users(id int(4) not null primary key auto_increment,type int
(4) not null,nusernmae char(30) not null, limits char(30) not null);
Query OK, 0 rows affected (0.61 sec)

mysql> desc Users;
+-----------+----------+------+-----+---------+----------------+
| Field     | Type     | Null | Key | Default | Extra          |
+-----------+----------+------+-----+---------+----------------+
| id        | int(4)   | NO   | PRI | NULL    | auto_increment |
| type      | int(4)   | NO   |     | NULL    |                |
| nusernmae | char(30) | NO   |     | NULL    |                |
| limits    | char(30) | NO   |     | NULL    |                |
+-----------+----------+------+-----+---------+----------------+
4 rows in set (0.02 sec)

mysql> create table Member(member int(4) not null primary key,logingName varchar

    -> (50) not null,loginPwd varchar(50) not null,realName varchar(50) not null
,email
    -> varchar(100) not null);
Query OK, 0 rows affected (0.31 sec)

mysql> desc Member;
+------------+--------------+------+-----+---------+-------+
| Field      | Type         | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| member     | int(4)       | NO   | PRI | NULL    |       |
| logingName | varchar(50)  | NO   |     | NULL    |       |
| loginPwd   | varchar(50)  | NO   |     | NULL    |       |
| realName   | varchar(50)  | NO   |     | NULL    |       |
| email      | varchar(100) | NO   |     | NULL    |       |
+------------+--------------+------+-----+---------+-------+
5 rows in set (0.02 sec)
mysql> desc member;
+------------+--------------+------+-----+---------+-------+
| Field      | Type         | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| member     | int(4)       | NO   | PRI | NULL    |       |
| logingName | varchar(50)  | NO   |     | NULL    |       |
| loginPwd   | varchar(50)  | NO   |     | NULL    |       |
| realName   | varchar(50)  | NO   |     | NULL    |       |
| email      | varchar(100) | NO   |     | NULL    |       |
+------------+--------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
mysql> create table Comments(CommentID int(4) not null primary key,reviewer int(
4),Title varchar(100) not null,Content Text(16) not null,CommentDate Datetime no
t null default now(),newsID int(4),foreign key(reviewer) references member(membe
r));
Query OK, 0 rows affected (0.48 sec)

mysql> create table section(sectionID int(4) not null primary key,sectionName va
rchar(30) not null,descrption varchar(100));
Query OK, 0 rows affected (0.38 sec)

mysql> desc section;
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| sectionID   | int(4)       | NO   | PRI | NULL    |       |
| sectionName | varchar(30)  | NO   |     | NULL    |       |
| descrption  | varchar(100) | YES  |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> create table news(NewsID int(4) not null primary key,submtDate datetime n
ot null default now(),Author varchar(50) not null,Title varchar(100) not null,Co
ntent text(16) not null,sectionID int(4),keyWords varchar(100),clickedTimes int(
4) not null,picture varchar(100) default null,foreign key(sectionID) references
section(sectionID));
Query OK, 0 rows affected (0.47 sec)

mysql> desc news;
+--------------+--------------+------+-----+-------------------+-------+
| Field        | Type         | Null | Key | Default           | Extra |
+--------------+--------------+------+-----+-------------------+-------+
| NewsID       | int(4)       | NO   | PRI | NULL              |       |
| submtDate    | datetime     | NO   |     | CURRENT_TIMESTAMP |       |
| Author       | varchar(50)  | NO   |     | NULL              |       |
| Title        | varchar(100) | NO   |     | NULL              |       |
| Content      | tinytext     | NO   |     | NULL              |       |
| sectionID    | int(4)       | YES  | MUL | NULL              |       |
| keyWords     | varchar(100) | YES  |     | NULL              |       |
| clickedTimes | int(4)       | NO   |     | NULL              |       |
| picture      | varchar(100) | YES  |     | NULL              |       |
+--------------+--------------+------+-----+-------------------+-------+
9 rows in set (0.02 sec)
mysql> alter table Comments add foreign key(newsID) references news(newsID);
Query OK, 0 rows affected (0.89 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc Comments;
+-------------+--------------+------+-----+-------------------+-------+
| Field       | Type         | Null | Key | Default           | Extra |
+-------------+--------------+------+-----+-------------------+-------+
| CommentID   | int(4)       | NO   | PRI | NULL              |       |
| reviewer    | int(4)       | YES  | MUL | NULL              |       |
| Title       | varchar(100) | NO   |     | NULL              |       |
| Content     | tinytext     | NO   |     | NULL              |       |
| CommentDate | datetime     | NO   |     | CURRENT_TIMESTAMP |       |
| newsID      | int(4)       | YES  | MUL | NULL              |       |
+-------------+--------------+------+-----+-------------------+-------+
6 rows in set (0.06 sec)

mysql>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值