数据库系统实验 - 简单的后台 - 作业笔记

数据库系统实验

本文并非完全按照实验要求,请勿抄袭,仅供参考


实验目的

  1. 了解DBMS系统的功能、Web based数据库的软件组成及工具;
  2. 掌握数据库软件的使用方法、
  3. 掌握php+mysql的数据库操作方法。

实验要求

  1. 安装相关软件并浏览软件自带的帮助文件和功能菜单,
  2. 掌握PHP构建网页以及连接数据库的方法。
  3. 掌握phpmyadmin创建数据库与数据表的方法;
  4. 了解mysql的命令以及与php衔接的语句
  5. 了解网页构造的原理
  6. 掌握dreamweaver的基本操作;

实验描述

  1. 建立一个php页面,打印出 现在的时间,同时计算出与2019年暑假(暑假开始日期:2019/7/15)相差的天数,用适当的方式显示
  2. 建立以下相关数据的数据库,并用一个页面显示所有的表名,即要求用户点击该表名显示出该表所有记录。并完成插入记录,删除记录以及修改记录的功能。

    注:所有的思考题均要求网页代码和运行后的界面。注意界面设计及美观性。

    Use the following SQL DDL statements to create the six tables required for this project. Note that you need to use the exact statements as shown below to ensure that the instructor can test your programs using the instructor’s data later. Please also note that the tables are created in certain order such that by the time when a foreign key needs to be created, the corresponding primary key has already been created.
    create table employees
    (
    eid varchar(3) not null,
    ename varchar(15),
    city varchar(15),
    primary key(eid)
    );
    create table customers
    (
    cid varchar(4) not null,
    cname varchar(15),
    city varchar(15),
    visits_made int(5),
    last_visit_time datetime,
    primary key(cid)
    );
    create table suppliers
    (
    sid varchar(2) not null,
    sname varchar(15) not null,
    city varchar(15),
    telephone_no char(10),
    primary key(sid),   
    unique(sname)
    );
    create table products
    (
    pid varchar(4) not null,
    pname varchar(15) not null,
    qoh int(5) not null,
    qoh_threshold int(5),
    original_price decimal(6,2),
    discnt_rate decimal(3,2),
    sid varchar(2),
    primary key(pid),   
    foreign key (sid) references suppliers (sid)
    );
    create table purchases
    (
    purid int not null,
    cid varchar(4) not null,
    eid varchar(3) not null,
    pid varchar(4) not null,
    qty int(5),
    ptime datetime,
    total_price decimal(7,2),
    primary key (purid),
    foreign key (cid) references customers(cid),
    foreign key (eid) references employees(eid),
    foreign key (pid) references products(pid)
    );
    create table logs
    (
    logid int(5) not null auto_increment,
    who varchar(10) not null,
    time datetime not null,
    table_name varchar(20) not null,
    operation varchar(6) not null,
    key_value varchar(4),
    primary key (logid)
    );
    insert into employees values ('e00', 'Amy', 'Vestal');
    insert into employees values ('e01', 'Bob', 'Binghamton');
    insert into employees values ('e02', 'John', 'Binghamton');
    insert into employees values ('e03', 'Lisa', 'Binghamton');
    insert into employees values ('e04', 'Matt', 'Vestal');
    insert into suppliers values ('s0', 'Supplier 1', 'Binghamton', '6075555431');
    insert into suppliers values ('s1', 'Supplier 2', 'NYC', '6075555432');
    insert into products values ('pr00', 'Milk', 12, 10, 2.40, 0.1, 's0');
    insert into products values ('pr01', 'Egg', 20, 10, 1.50, 0.2, 's1');
    insert into products values ('pr02', 'Bread', 15, 10, 1.20, 0.1, 's0');
    insert into products values ('pr03', 'Pineapple', 6, 5, 2.00, 0.3, 's0');
    insert into products values ('pr04', 'Knife', 10, 8, 2.50, 0.2, 's1');
    insert into products values ('pr05', 'Shovel', 5, 5, 7.99, 0.1, 's0');
    insert into customers values ('c000', 'Kathy', 'Vestal', 2, '2017-11-28 10:25:32'); 
    insert into customers values ('c001', 'Brown', 'Binghamton', 1, '2013-12-05 09:12:30'); 
    insert into customers values ('c002', 'Anne', 'Vestal', 1, '2016-11-29 14:30:00'); 
    insert into customers values ('c003', 'Jack', 'Vestal', 1, '2016-12-04 16:48:02'); 
    insert into customers values ('c004', 'Mike', 'Binghamton', 1, '2016-11-30 11:52:16'); 
    insert into purchases values (1, 'c000', 'e00', 'pr00', 1, '2017-10-22 12:34:22', 2.16);
    insert into purchases values (2, 'c001', 'e03', 'pr03', 2, '2016-12-05 09:12:30', 2.80);
    insert into purchases values (3, 'c002', 'e03', 'pr00', 1, '2016-11-29 14:30:00', 2.16);
    insert into purchases values (4, 'c000', 'e01', 'pr01', 5, '2016-11-28 10:25:32', 6.00);
    insert into purchases values (5, 'c004', 'e04', 'pr02', 3, '2016-11-30 11:52:16', 3.24);
    insert into purchases values (6, 'c003', 'e02', 'pr05', 1, '2016-12-04 16:48:02', 7.19);

    此次实验实验Laragon + Laravel 做一次尝试

虽然实验上推荐使用 WampServer 以及其他一些集成开发环境,但是综合使用情况来看这些集成开发环境依旧麻烦,所以这里推荐使用 Laragon 无论安装什么都变得十分简单,适合 Windows 环境,是当前我用过认为最好的 Windows 集成开发环境。

Laragon 安装

参考链接 laragon 与 laravel 安装

Laravel 项目

安装好 Laragon 后

准备知识

laravel 文档部分

前端部分

数据库部分

开始项目