Fakultas Ilmu Komputer UI

Commit 15967ad5 authored by Andhar1's avatar Andhar1
Browse files

Modify database

parent d95c6561
Pipeline #18971 failed with stage
in 5 seconds
INSERT INTO vets VALUES (1, 'James', 'Carter');
INSERT INTO vets VALUES (2, 'Helen', 'Leary');
INSERT INTO vets VALUES (3, 'Linda', 'Douglas');
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega');
INSERT INTO vets VALUES (5, 'Henry', 'Stevens');
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins');
INSERT INTO vets VALUES (1, 'James', 'Carter', 10);
INSERT INTO vets VALUES (2, 'Helen', 'Leary', 10);
INSERT INTO vets VALUES (3, 'Linda', 'Douglas', 10);
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega', 10);
INSERT INTO vets VALUES (5, 'Henry', 'Stevens', 10);
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins', 10);
INSERT INTO specialties VALUES (1, 'radiology');
INSERT INTO specialties VALUES (2, 'surgery');
......@@ -22,6 +22,9 @@ INSERT INTO types VALUES (4, 'snake');
INSERT INTO types VALUES (5, 'bird');
INSERT INTO types VALUES (6, 'hamster');
INSERT INTO gender VALUES (1, 'male');
INSERT INTO gender VALUES (2, 'female');
INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
......@@ -33,21 +36,22 @@ INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1);
INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 2);
INSERT INTO pets VALUES (3, 'Rosy', '2011-04-17', 2, 3);
INSERT INTO pets VALUES (4, 'Jewel', '2010-03-07', 2, 3);
INSERT INTO pets VALUES (5, 'Iggy', '2010-11-30', 3, 4);
INSERT INTO pets VALUES (6, 'George', '2010-01-20', 4, 5);
INSERT INTO pets VALUES (7, 'Samantha', '2012-09-04', 1, 6);
INSERT INTO pets VALUES (8, 'Max', '2012-09-04', 1, 6);
INSERT INTO pets VALUES (9, 'Lucky', '2011-08-06', 5, 7);
INSERT INTO pets VALUES (10, 'Mulligan', '2007-02-24', 2, 8);
INSERT INTO pets VALUES (11, 'Freddy', '2010-03-09', 5, 9);
INSERT INTO pets VALUES (12, 'Lucky', '2010-06-24', 2, 10);
INSERT INTO pets VALUES (13, 'Sly', '2012-06-08', 1, 10);
INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1, 1, NULL, NULL);
INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 1, 2, NULL, NULL);
INSERT INTO pets VALUES (3, 'Rosy', '2011-04-17', 2, 2, 3, NULL, NULL);
INSERT INTO pets VALUES (4, 'Jewel', '2010-03-07', 2, 2, 3, NULL, NULL);
INSERT INTO pets VALUES (5, 'Iggy', '2010-11-30', 3, 2, 4, NULL, NULL);
INSERT INTO pets VALUES (6, 'George', '2010-01-20', 4, 1, 5, NULL, NULL);
INSERT INTO pets VALUES (7, 'Samantha', '2012-09-04', 1, 2, 6, NULL, NULL);
INSERT INTO pets VALUES (8, 'Max', '2012-09-04', 1, 1, 6, NULL, NULL);
INSERT INTO pets VALUES (9, 'Lucky', '2011-08-06', 5, 2, 7, NULL, NULL);
INSERT INTO pets VALUES (10, 'Mulligan', '2007-02-24', 2, 2, 8, NULL, NULL);
INSERT INTO pets VALUES (11, 'Freddy', '2010-03-09', 5, 1, 9, NULL, NULL);
INSERT INTO pets VALUES (12, 'Lucky', '2010-06-24', 2, 2, 10, NULL, NULL);
INSERT INTO pets VALUES (13, 'Sly', '2012-06-08', 1, 2, 10, NULL, NULL);
INSERT INTO visits VALUES (1, 7, '2013-01-01', 'rabies shot');
INSERT INTO visits VALUES (2, 8, '2013-01-02', 'rabies shot');
INSERT INTO visits VALUES (3, 8, '2013-01-03', 'neutered');
INSERT INTO visits VALUES (4, 7, '2013-01-04', 'spayed');
......@@ -22,7 +22,8 @@ CREATE INDEX specialties_name ON specialties (name);
CREATE TABLE vet_specialties (
vet_id INTEGER NOT NULL,
specialty_id INTEGER NOT NULL
specialty_id INTEGER NOT NULL,
price INTEGER NOT NULL
);
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets (id);
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id);
......@@ -48,17 +49,23 @@ CREATE TABLE pets (
name VARCHAR(30),
birth_date DATE,
type_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL
owner_id INTEGER NOT NULL,
father_id INTEGER,
mother_id INTEGER
);
ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners (id);
ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types (id);
ALTER TABLE pets ADD CONSTRAINT fk_pets_father FOREIGN KEY (father_id) REFERENCES pets (id);
ALTER TABLE pets ADD CONSTRAINT fk_pets_mother FOREIGN KEY (mother_id) REFERENCES pets (id);
CREATE INDEX pets_name ON pets (name);
CREATE TABLE visits (
id INTEGER IDENTITY PRIMARY KEY,
pet_id INTEGER NOT NULL,
visit_date DATE,
description VARCHAR(255)
description VARCHAR(255),
price INTEGER NOT NULL
);
ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets (id);
CREATE INDEX visits_pet_id ON visits (pet_id);
<html xmlns:th="http://www.x3.org/1999/xhtml">
<body>
<form>
<th:block th:fragment="select (label, name, items)">
<div th:with="valid=${!#fields.hasErrors(name)}"
th:class="${'form-group' + (valid ? '' : ' has-error')}"
class="form-group">
<label class="col-sm-2 control-label" th:text="${label}">Label</label>
<div class="col-sm-10">
<select th:field="*{__${name}__}">
<option th:each="item : ${items}" th:value="${item.id}"
th:text="${item.name}">dog</option>
</select>
<span th:if="${valid}"
class="glyphicon glyphicon-ok form-control-feedback"
aria-hidden="true"></span>
<th:block th:if="${!valid}">
<span
class="glyphicon glyphicon-remove form-control-feedback"
aria-hidden="true"></span>
<span class="help-inline" th:errors="*{__${name}__}">Error</span>
</th:block>
</div>
</div>
</th:block>
</form>
</body>
</html>
\ No newline at end of file
......@@ -50,6 +50,10 @@
th:text="${#temporals.format(pet.birthDate, 'yyyy-MM-dd')}" /></dd>
<dt>Type</dt>
<dd th:text="${pet.type}" /></dd>
<dt>Father</dt>
<dd th:text="${pet.father}" /><dd>
<dt>Mother</dt>
<dd th:text="${pet.mother}" /><dd>
</dl>
</td>
<td valign="top">
......
......@@ -22,6 +22,10 @@
th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate', 'date')}" />
<input
th:replace="~{fragments/selectField :: select ('Type', 'type', ${types})}" />
<input
th:replace="~{fragments/selectFieldParent :: select ('Father', 'father', ${petz})}" />
<input
th:replace="~{fragments/selectFieldParent :: select ('Mother', 'mother', ${petz})}" />
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
......@@ -35,4 +39,4 @@
</body>
</html>
\ No newline at end of file
</html>
INSERT INTO vets VALUES (1, 'James', 'Carter', NULL);
INSERT INTO vets VALUES (2, 'Helen', 'Leary', NULL);
INSERT INTO vets VALUES (3, 'Linda', 'Douglas', NULL);
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega', NULL);
INSERT INTO vets VALUES (5, 'Henry', 'Stevens', NULL);
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins', NULL);
INSERT INTO vets VALUES (1, 'James', 'Carter', 10);
INSERT INTO vets VALUES (2, 'Helen', 'Leary', 10);
INSERT INTO vets VALUES (3, 'Linda', 'Douglas', 10);
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega', 10);
INSERT INTO vets VALUES (5, 'Henry', 'Stevens', 10);
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins', 10);
INSERT INTO specialties VALUES (1, 'radiology');
INSERT INTO specialties VALUES (2, 'surgery');
......
......@@ -22,7 +22,8 @@ CREATE INDEX specialties_name ON specialties (name);
CREATE TABLE vet_specialties (
vet_id INTEGER NOT NULL,
specialty_id INTEGER NOT NULL
specialty_id INTEGER NOT NULL,
price INTEGER NOT NULL
);
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets (id);
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment