This tutorial uses PostgreSQL on a Linux OS (Ubuntu). Before begining, you wil have to install and set up PostgreSQL.
✶ Install PostgreSQL (Linux, Windows, OSX)
✶ Setup PostgreSQL (Ubuntu)
✶ psql commands
✶ Tables + Queries
✶ Set up Oracle VB with Ubuntu
We will call the character classes "card types" and stick them in a "card_types" table.
-- Card types table
create table if not exist card_types (
id serial,
my_timestamp timestamp
default current_timestamp,
name varchar,
intelligence integer,
strength integer,
dex integer,
spirituality integer,
brutality integer,
diplomacy integer,
PRIMARY KEY (user_id)
);
➼ id - A unique numerical idetifier that we will use for our primary key.
➼ my_timestamp - Automatically insert a timestamp when a data entry is inserted.
➼ name - The name of the card type. varchar datatype is like a string.
➼ skills - Finally, we have a column for each skill. Each skill is an integer 1-20.
➼ name
➼ intelligence
➼ stregth
➼ dex
➼ spirituality
➼ brutality
➼ diplomacy
ccBattleCards=# select * from card_types;
Next we will create our cards table. It references card_types because each card character belongs to a character class.
When one table references another table, we can use a foreign key constrate. In relational databases, one table's primary key is often another table's foreign key.
-- cards table: references card_types (id)
create table cards (
id serial,
my_timestamp timestamp default current_timestamp,
name varchar,
image varchar,
alignment integer,
type_id integer references card_types(id)
);
➼ type_id - The name of the column which holds our foriegn key.
➼ integer - Datatype
➼ card_types - The Table we are referencing
➼ id - The column we are referencing
insert into cards (name,image,alignment,type_id)
values ('Paladin Hatnix','paladin-hatnix.png', 0, 1),
('Sir Diealot','sir-diealot.png', 0, 2),
('Priestess Jill','priestess-jill.png', 0, 3),
('Afro Wolf','afro-wolf.png',0, 4),
('Tux Digi-Wolf', 'digital-tux.png', 0, 4),
('Verrucktes Huhn', 'crazy-chicken.png', 1, 5),
('Vampire Mage', 'eva-mage.png', 0, 5),
('Doove Druid', 'doove-druid.png',0,6),
('Shayna Madela', 'nahama.jpg', 0, 6),
('Master Warrior', 'nahama.jpg', 1, 8),
('John Smith', 'john-smith.png', 1, 8),
('StregthInside Unicorn', 'strength-unicorn.png',0,10);