Select branch sumbalance from accounts group by

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ibrary(RSQLite)! # set up an interface to SQLite! M = dbDriver("SQLite")! # connect to particular DBMS (no security SQLite)! con = dbConnect(m, dbname="tfile")! # submit an SQL statement; returns a data frame! dbGetQuery(con, "SELECT * FROM chipsSQLite LIMIT 5;")! If the results are large, we don’t have to pull them all over into R at once. # submit an SQL statement; but keep results in SQL! rs = dbSendQuery(con, "SELECT * FROM chipsSQLite;")! ! # Retrieve the first 5 rows in the results! fetch(rs, n = 5)! ! # Retrieve the next 3 rows! fetch(rs, n = 3)! ! # Retrieve the remaining rows! fetch(rs, n = -1)! ! # Close the query! dbClearResult(rs)! We can of course import the whole table, then extrac;ng what we want using R commands. But, it may be more efficient to use SELECT to extract and import only the results with which we want to work Mul;ple Tables •  Where do you see redundancy? •  What might an en;ty be? (e.g. lab test) BANK BRANCH •  Where do you see redundancy? •  What might an en;ty be? (e.g. lab test) BANK BRANCH CUSTOMER •  Where do you see redundancy? •  What might an en;ty be? (e.g. lab test) BANK CUSTOMER ACCOUNT •  Where do you see redundancy? •  What might an en;ty be? (e.g. lab test) En;;es •  Customer: –  Customers can have more than one account •  Account: –  Accounts can be owned by more than one customer; –  An account is in one branch •  Branch: –  Branches can have many accounts •  Here are tables for each of the three en;;es we iden;fied. Is anything missing? We have informa'on about: Customers Accounts Branch Missing Informa;on •  Rela;ons: –  Customers have accounts –  Accounts are located in Branches •  How do we bring this informa;on into the database? –  Add branch informa;on to the acco...
View Full Document

This document was uploaded on 02/16/2014 for the course STATISTICS 3026 at Columbia.

Ask a homework question - tutors are online