The Fourth Lab
Install and Learn PostgreSQL (II)
(I) FAQ for Lab 3
Use your BU username and password to log on cs460.bu.edu server.
The cs460.bu.edu server cannot read the file in your local machine.
(a) If you are using your own machine, the data file should be in your machine.
(b) If you are using cs460.bu.edu server, make sure the data file should be on the server.
(a) In windows machines, the "Z" drive is your home folder. The files in "Z" drive is the same as the files in your linux home folder.
(b) The files in the home folder on csa2 or csa3 server is the same as the files in the home folder on cs460 server.
(c) You can put the files in "Z" drive and read the files in Linux terminal.
(d) You can upload the files to csa2 or csa3 server and read the files on cs460 server.
(a) For example: "ls", "head", "tail", "more", "less" and "cat" are limux commands. Do not use them in PostgreSQL database shell.
(b) For example: "/copy", "select", and "create" are PostgreSQL database commands. Do not use them in Linux terminal.
(a) If you see "=>", it means you are typing a new statement in PostgreSQL database shell.
(b) If you see "->", it means you continue to type the previous statement.
(a) Please read the README file shown in error message and change the configuration file on your Mac.
(b) You should change kern.sysv.shmmax to a larger number (larger than 32M).
(II) Copy or Download Files to Server
For example, after you log on to csa2 or csa3 server, type wget http://files.hubwaydatachallenge.org/hubway_2011_07_through_2013_11.zip in terminal to download the data file for Lab 3.
For example, in your Mac or Linux machines, open a terminal and go to the directory of your file to be copied. Type scp [filename] [username]@csa2.bu.edu:~ in terminal to copy the files.
(a) Download the FileZilla client and install it on your own machine.
(b) Open the FileZilla client.
(c) Type sftp://csa2.bu.edu in Host.
(c) Type your BU username and BU password.
(d) Type 22 in Port.
(e) Connect the server and upload your files.
(III) Linux commands
(a) The most important command.
(b) If you do not know how to use a command, read its manual first.
(c) For example, type man ls to show the manual of command ls .
(IV) PostgreSQL commands
(V) Relational Algebra
(VI) Solution to Exercise of Lab 3
CREATE TABLE trips (
seq_id integer,
hubway_id integer,
status varchar(20),
duration integer,
start_date timestamp,
strt_statn integer,
end_date timestamp,
end_statn integer,
bike_nr char(6),
subsc_type varchar(20),
zip_code varchar(6),
birth_date integer,
gender varchar(6)
);
\copy trips from '~/Downloads/hubway_trips_sample.csv' CSV HEADER;