Skip to content

Commit

Permalink
improvement the schema. Adapting insert_values to new schema. Adding …
Browse files Browse the repository at this point in the history
…insert_rules
  • Loading branch information
bmejias committed Sep 20, 2011
1 parent e156a51 commit adb4177
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
7 changes: 3 additions & 4 deletions database/pgsql_create_schema.sql
Expand Up @@ -41,10 +41,9 @@ CREATE TABLE groups

CREATE TABLE group_users
(
id serial,
id serial PRIMARY KEY,
user_id serial REFERENCES users(id),
group_id serial REFERENCES groups(id),
PRIMARY KEY (user_id, group_id)
group_id serial REFERENCES groups(id)
);

CREATE TABLE loans
Expand All @@ -55,7 +54,7 @@ CREATE TABLE loans
date_out date NOT NULL,
date_in date,
status varchar(16) NOT NULL,
money int
money money
);

CREATE TABLE rules
Expand Down
16 changes: 16 additions & 0 deletions database/pgsql_insert_rules.sql
@@ -0,0 +1,16 @@
/* default amount of days a book is lent */
INSERT INTO rules (rule, amount, note)
VALUES ('lend', 14, 'days');

/* amount of delayed days to apply a fine */
INSERT INTO rules (rule, amount, note)
VALUES ('fine_days', 1, 'days');

/* amount of cents to be payed for every fine_days */
INSERT INTO rules (rule, amount, note)
VALUES ('fine_money', 10, 'cents');

/* deposit in case of taken media material */
INSERT INTO rules (rule, amount, note)
VALUES ('deposit', 50, 'cents');

2 changes: 1 addition & 1 deletion database/pgsql_insert_values.sql
Expand Up @@ -4,7 +4,7 @@ INSERT INTO groups (name)
INSERT INTO users (username, first_name, last_name, email, password)
VALUES ('saartje', 'Saartje', 'Renaers', 'saartje@renaers.be', 'topsecret');

INSERT INTO user_group (user_id, group_id)
INSERT INTO group_users (user_id, group_id)
VALUES ((SELECT id FROM groups WHERE name='admin'),
(SELECT id FROM users WHERE username='saartje'));

0 comments on commit adb4177

Please sign in to comment.