資料庫課程作業筆記

MARTINPOTTER發表於2019-04-24

試驗僅作為記錄,學習,請用於學習用途
開源專案 github 程式碼地址


實驗目的

  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 文件部分

前端部分

資料庫部分

開始專案

MARTINPOTTER

相關文章