1 / 30

CS162 Discussion Notes

CS162 Discussion Notes. March 31, 2011 Jorge Ortiz. Paul A. Strassmann , George Mason University Rightscale.com Kirk Anne, SUNY Geneseo Randy Katz, UC Berkeley. Acknowledgements. Outline. Cloud computing What is it? Virtualization Hypervisor configurations Amazon EC2

Download Presentation

CS162 Discussion Notes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS162 Discussion Notes March 31, 2011 Jorge Ortiz

  2. Paul A. Strassmann, George Mason University Rightscale.com Kirk Anne, SUNY Geneseo Randy Katz, UC Berkeley Acknowledgements

  3. Outline • Cloud computing • What is it? • Virtualization • Hypervisor configurations • Amazon EC2 • Relational databases • Entity relationship diagrams • Data models • Imperative versus declarative • SQL

  4. What is cloud computing? • Cloud computing is Internet-based computing, whereby shared resources, software and information are provided to computers and other devices on-demand, like electricity • Wikipedia

  5. Data Centers Google’s Containerized Datacenter MicrosoftChicago Datacenter

  6. What runs on these machines? • All types of applications! • How can we make bestuse of the resources?

  7. Virtualization (2)

  8. Virtualization (3)

  9. Amazon EC2 Architecture

  10. Applications • Web applications • Databases • Compute-intensive jobs • Client-Server applications • Project 3! • Chat Server will be in the cloud • Clients will be outside the cloud • Application state stored in database

  11. Parts of a database Record Tables Attribute/Field • Records become “rows” • Attributes/fields become “columns” • Rules determine the relationship between the tables and tie the data together to form a database

  12. Basic SQL Commands • Creating tables with CREATE • Adding data with INSERT • Viewing data with SELECT • Removing data with DELETE • Modifying data with UPDATE • Destroying tables with DROP

  13. Creating tables with CREATE • Generic form CREATE TABLE tablename ( column_name data_type attributes…, column_name data_type attributes…, … ) • Table and column names can’t have spaces or be “reserved words” like TABLE, CREATE, etc.

  14. Phone Book/Contact Table CREATE TABLE contacts ( Name VARCHAR(40), Address VARCHAR(60), Company VARCHAR(60), Phone VARCHAR(11), URL VARCHAR(80), Age INT, Height FLOAT, Birthday DATE, WhenEntered TIMESTAMP ); Plan your tables very carefully! Once created, they are difficult to change!

  15. Data Types • Binary • Database specific binary objects (BLOB) • Boolean • True/False values (BOOLEAN) • Character • Fixed width (CHAR) or variable size (VARCHAR) • Numeric • Integer (INT), Real (FLOAT), Money (MONEY) • Temporal • Time (TIME), Date (DATE), Timestamp (TIMESTAMP)

  16. Adding data with INSERT • Generic Form INSERT INTO tablename (column_name,…) VALUES (value,…)

  17. Inserting a record into ‘contacts’ INSERT INTO contacts (contactid,name,address,company,phone,url,age,height,birthday,whenentered) VALUES (1,‘Joe’,’123 Any St.’,’ABC’, ’800-555-1212’,‘http://abc.com’,30,1.9,’6/14/1972’,now());

  18. Inserting a partial record INSERT INTO contacts (contactid,name,phone) VALUES (2,’Jane’,’212-555-1212’);

  19. Automatic key generation • CREATE SEQUENCE contactidseq; • Change the ContactID line in the CREATE TABLE to: ContactID INT DEFAULT nextval(‘contactidseq’) PRIMARY KEY • Or when inserting into a table INSERT contacts (contactid,name,phone) VALUES (nextval(‘contactidseq’),’Jack’,‘716-555-1212’);

  20. Viewing data with SELECT • Generic Form SELECT column,… FROM table,… WHERE condition GROUP BY group_by_expressionHAVING condition ORDER BY order_expression • The most used command • Probably the most complicated also • If used improperly, can cause very long waits because complex computations

  21. A few simple SELECTs • SELECT * FROM contacts; • Display all records in the ‘contacts’ table • SELECT contactid,name FROM contacts; • Display only the record number and names • SELECT DISTINCT url FROM contacts; • Display only one entry for every value of URL.

  22. Refining selections with WHERE • The WHERE “subclause” allows you to select records based on a condition. • SELECT * FROM contacts WHERE age<10; • Display records from contacts where age<10 • SELECT * FROM contacts WHERE age BETWEEN 18 AND 35; • Display records where age is 18-35

  23. Additional selections • The “LIKE” condition • Allows you to look at strings that are alike • SELECT * FROM contacts WHERE name LIKE ‘J%’; • Display records where the name starts with ‘J’ • SELECT * FROM contacts WHERE url LIKE ‘%.com’; • Display records where url ends in “.com”

  24. Removing data with DELETE • Generic Form DELETE FROM table WHERE condition; DELETE FROM contacts WHERE age<13;

  25. Modifying data with UPDATE • Generic Form UPDATE table SET column=expression WHERE condition; UPDATE contacts SET company=‘AOL’ WHERE company=‘Time Warner’;

  26. Destroying tables with DROP • Generic Form DROP TABLE tablename; DROP TABLE contacts;

  27. Joining together tables • SELECT name,phone,zip FROM people, phonenumbers, address WHERE people.addressid=address.addressid AND people.id=phonenumbers.id;

  28. GROUP BY/HAVING • The “GROUP BY” clause allows you to group results together with “aggregate functions” • AVG(), COUNT(), MAX(), MIN(), SUM() • COUNT DISTINCT • HAVING allows you to search the GROUP BY results

  29. Important links • http://aws.amazon.com/documentation/ec2/ • http://www.mysql.com/

More Related