28 Pages

mySQL

Course: COMP 519, Fall 2009
School: East Los Angeles College
Rating:
 
 
 
 
 

Word Count: 2634

Document Preview

Web COMP519: Programming Autumn 2008 In the next lectures you will learn What is SQL How to access mySQL database How to create a basic mySQL database How to use some basic queries How to use PHP and mySQL Introduction to SQL SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating databases. SQL stands for Structured Query Language using SQL can you...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> East Los Angeles College >> COMP 519

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Web COMP519: Programming Autumn 2008 In the next lectures you will learn What is SQL How to access mySQL database How to create a basic mySQL database How to use some basic queries How to use PHP and mySQL Introduction to SQL SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating databases. SQL stands for Structured Query Language using SQL can you can access a database execute queries, and retrieve data insert, delete and update records SQL works with database programs like MS Access, DB2, Informix, MS SQL Server, Oracle, Sybase, mySQL, etc. Unfortunately, there are many different versions. But, they must support the same major keywords in a similar manner such as SELECT, UPDATE, DELETE, INSERT, WHERE, etc. Most of the SQL database programs also have their own proprietary extensions! The University of Liverpool CS department has a version of mySQL installed on the servers, and it is this system that we use in this course. Most all of the commands discussed here should work with little (or no) change to them on other database systems. SQL Database Tables A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data. For example, a table called "Persons": LastName Hansen Svendson Pettersen FirstName Ola Tove Kari Address Timoteivn 10 Borgvn 23 Storgt 20 City Sandnes Sandnes Stavanger The table above contains three records (one for each person) and four columns (LastName, FirstName, Address, and City). SQL Queries With SQL, you can query a database and have a result set returned. A query like this: SELECT LastName FROM Persons; gives a result set like this: LastName Hansen Svendson Pettersen The mySQL database system requires a semicolon at the end of the SQL statement! SQL Data Languages The query and update commands together form the Data Manipulation Language (DML) part of SQL: SELECT - extracts data from a database table UPDATE - updates data in a database table DELETE - deletes data from a database table INSERT INTO - inserts new data into a database table The Data Definition Language (DDL) part of SQL permits database tables to be created or deleted: CREATE TABLE - creates a new database table ALTER TABLE - alters (changes) a database table DROP TABLE - deletes a database table CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index *Here we will use some of them in mySQL Logging into mySQL Server You can log into our mySQL server from Linux by typing in the prompt bash-2.05b$ mysql -h mysql martin u martin Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 209201 to server version: 5.0.22 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> From here you can create, modify, and and drop tables, and modify the data in your tables. But first, you must specify which database on the server you want to use. mysql> use martin; Database changed Technical note You probably dont need to worry about this, but thought I would mention it here Most books and on-line tutorials assume the database server is running on the same machine as everything else, and that the user is "root". Neither of these are true here. Wherever you see "localhost", replace it by "mysql" Wherever you see "root", replace it with your username. (Ignore this if you dont understand it for now, or are not consulting other references.) Creating a Table You can create a table you might use for the upcoming project. For example, mysql> CREATE TABLE students( -> num INT NOT NULL AUTO_INCREMENT, -> f_name VARCHAR(48), -> l_name VARCHAR(48), -> student_id INT, -> email VARCHAR(48), -> PRIMARY KEY(num)); Hit Enter after each line (if you want). MySQL doesnt try to interpret the command itself until it sees a semicolon (;) (The -> characters you see are not typed by you.) Query OK, 0 rows affected (0.02 sec) *If the server gives you a big ERROR, just try again from the top! Viewing The Table Structure Use DESCRIBE to see the structure of a table mysql> DESCRIBE students; +------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+----------------+ | num | int(11) | NO | PRI | NULL | auto_increment | | f_name | varchar(48) | YES | | NULL | | | l_name | varchar(48) | YES | | NULL | | | student_id | int(11) | YES | | NULL | | | email | varchar(48) | YES | | NULL | | +------------+-------------+------+-----+---------+----------------+ Inserting Data Using INSERT INTO you can insert a new row into your table. For example, mysql> INSERT INTO students -> VALUES(NULL,Russell,Martin,396310,martin@csc.liv.ac.uk'); Query OK, 1 row affected (0.00 sec) Using SELECT FROM you select some data from a table. mysql> SELECT * FROM students; +-----+---------+--------+------------+----------------------+ | num | f_name | l_name | student_id | email | +-----+---------+--------+------------+----------------------+ | 1 | Russell | Martin | 396310 | martin@csc.liv.ac.uk | +-----+---------+--------+------------+----------------------+ 1 row in set (0.00 sec) Inserting Some More Data You can repeat inserting until all data is entered into the table. mysql> INSERT INTO students -> VALUES(NULL,James',Bond',007,'bond@csc.liv.ac.uk'); Query OK, 1 row affected (0.01 sec) mysql> SELECT * FROM students; +-----+---------+--------+------------+----------------------+ | num | f_name | l_name | student_id | email | +-----+---------+--------+------------+----------------------+ | 1 | Russell | Martin | 396310 | martin@csc.liv.ac.uk | | 2 | James | Bond | 7 | bond@csc.liv.ac.uk | +-----+---------+--------+------------+----------------------+ 2 rows in set (0.00 sec) Note: The value NULL in the num field is automatically replaced by the SQL interpreter as the auto_increment option was selected when the table was defined. Getting Data Out of the Table The SELECT command is the main way of getting data out of a table, or set of tables. SELECT * FROM students; Here the asterisk means to select (i.e. return the information in) all columns. You can specify one or more columns of data that you want, such as SELECT f_name,l_name FROM students; +---------+--------+ | f_name | l_name | +---------+--------+ | Russell | Martin | | James | Bond | +---------+--------+ 2 rows in set (0.00 sec) Getting Data Out of the Table (cont.) You can specify other information that you want in the query using the WHERE clause. SELECT * FROM students WHERE l_name=Bond; +-----+---------+--------+------------+----------------------+ | num | f_name | l_name | student_id | email | +-----+---------+--------+------------+----------------------+ | 2 | James | Bond | 7 | bond@csc.liv.ac.uk | +-----+---------+--------+------------+----------------------+ 1 row in set (0.00 sec) SELECT student_id, email FROM students WHERE l_name=Bond; +------------+----------------------+ | student_id | email | +------------+----------------------+ | 7 | bond@csc.liv.ac.uk | +------------+----------------------+ 1 row in set (0.00 sec) Altering the Table The ALTER TABLE statement is used to add or drop columns in an existing table. mysql> ALTER TABLE students ADD date DATE; Query OK, 2 rows affected (0.00 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> SELECT * FROM students; +-----+---------+--------+------------+----------------------+------+ | num | f_name | l_name | student_id | email | date | +-----+---------+--------+------------+----------------------+------+ | 1 | Russell | Martin | 396310 | martin@csc.liv.ac.uk | NULL | | 2 | James | Bond | 7 | bond@csc.liv.ac.uk | NULL | +-----+---------+--------+------------+----------------------+------+ 2 rows in set (0.00 sec) Updating the Table The UPDATE statement is used to modify data in a table. mysql> UPDATE students SET date='2007-11-15' WHERE num=1; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> SELECT * FROM students; +-----+---------+--------+------------+----------------------+------------+ | num | f_name | l_name | student_id | email | date | +-----+---------+--------+------------+----------------------+------------+ | 1 | Russell | Martin | 396310 | martin@csc.liv.ac.uk | 2007-11-15 | | 2 | James | Bond | 7 | bond@csc.liv.ac.uk | NULL | +-----+---------+--------+------------+----------------------+------------+ 2 rows in set (0.00 sec) Note that the default date format is YYYY-MM-DD and I dont believe this default setting can be changed. Deleting Some Data The DELETE statement is used to delete rows in a table. mysql> DELETE FROM students WHERE l_name='Bond'; Query OK, 1 row affected (0.00 sec) mysql> SELECT * FROM students; +-----+---------+--------+------------+----------------------+------------+ | num | f_name | l_name | student_id | email | date | +-----+---------+--------+------------+----------------------+------------+ | 1 | Russell | Martin | 396310 | martin@csc.liv.ac.uk | 2006-11-15 | +-----+---------+--------+------------+----------------------+------------+ 1 row in set (0.00 sec) The Final Table Well first add another column, update the (only) record, then insert more data. mysql> ALTER TABLE students ADD gr INT; Query OK, 1 affected row (0.01 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> SELECT * FROM students; +-----+---------+--------+------------+----------------------+------------+------+ | num | f_name | l_name | student_id | email | date | gr | +-----+---------+--------+------------+----------------------+------------+------+ | 1 | Russell | Martin | 396310 | martin@csc.liv.ac.uk | 2007-11-15 | NULL | +-----+---------+--------+------------+----------------------+------------+------+ 1 row in set (0.00 sec) mysql> UPDATE students SET gr=3 WHERE num=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> SELECT * FROM students; +-----+---------+--------+------------+----------------------+------------+------+ | num | f_name | l_name | student_id | email | date | gr | +-----+---------+--------+------------+----------------------+------------+------+ | 1 | Russell | Martin | 396310 | martin@csc.liv.ac.uk | 2007-11-15 | 3 | +-----+---------+--------+------------+----------------------+------------+------+ 1 row in set (0.00 sec) mysql> INSERT INTO students VALUES(NULL,James',Bond',007,'bond@csc.liv.ac.uk,200711-15, 1); . . . . . . The Final Table (cont.) . . . . . . mysql> INSERT INTO students VALUES(NULL,Hugh,Milner',75849789,hugh@poughkeepsie.ny, CURRENT_DATE, 2); Note: CURRENT_DATE is a built-in SQL command which (as expected) gives the current (local) date. mysql> SELECT * FROM students; +-----+---------+----------+------------+----------------------------+------------+------+ | num | f_name | l_name | student_id | email | date | gr | +-----+---------+----------+------------+----------------------------+------------+------+ | | | | | | | 1 | Russell | Martin 5 | Kate 3 | James 4 | Bob 6 | Pete 7 | Polly 8 | Hugh | Ash | Bond | Jones | Lofton | | | | | 396310 | martin@csc.liv.ac.uk 124309 | kate@ozymandius.co.uk 7 | bond@csc.liv.ac.uk 12190 | bob@nowhere.com | 2007-11-15 | | 2007-11-16 | | 2007-11-15 | | 2007-11-16 | 3 | 3 | 1| 3 | 2 | 1| 2 | 76 | lofton@iwannabesedated.com | 2007-11-17 | 1717 | crackers@polly.org 75849789 | hugh@poughkeepsie.ny | 2007-11-17 | | 2007-11-17 | | Crackers | | Milner | +-----+---------+----------+------------+----------------------------+------------+------+ 7 rows in set (0.00 sec) mysql> exit Bye Other SQL Commands SHOW tables; gives a list of tables that have been defined in the database ALTER TABLE students DROP email; would drop the email column from all records DROP TABLE students; deletes the entire students table, and its definition (use the DROP command with extreme care!!) DELETE FROM students; removes all rows from the students table (so once again, use the DELETE command with great caution), the table definition remains to be used again A more useful command is something like DELETE FROM students WHERE (num > 5) AND (num <= 10); which selectively deletes students based on their num values (for example). HELP; gives the SQL help HELP DROP; gives help on the DROP command, etc. Backing up/restoring a mySQL database You can back up an entire database with a command such as mysqldump h mysql u martin martin > backup.sql (Run from the Unix command line.) This gives a script containing SQL commands to reconstruct the table structure (of all tables) and all of the data in the table(s). To restore the database (from scratch) you can use this type of Unix command: mysql h mysql u martin martin < backup.sql Other commands are possible to backup/restore only certain tables or items in tables, etc. if that is what you desire. For example mysqldump h mysql u martin martin books clients> backup.sql stores information about the books and clients tables in the martin database. Putting Content into Your Database with PHP We can simply use PHP functions and mySQL queries together: Connect to the database server and login (this is the PHP command to do so) mysql_connect("host","username","password"); Choose the database mysql_select_db("database"); Host: Database: Username: Password: mysql martin martin <blank> Send SQL queries to the server to add, delete, and modify data mysql_query("query"); (use the exact same query string as you would normally use in SQL, without the trailing semi-colon) Close the connection to the database server (to ensure the information is stored properly) mysql_close(); Note: For this to work properly on the UoL server, you must access the PHP script through the cgi server (http://cgi.csc.liv.ac.uk/~martin/getstuff.php for example). Student Database: data_in.php <html> <head> <title>Putting Data in the DB</title> </head> <body> <?php /*insert students into DB*/ if(isset($_POST["submit"])) { $db = mysql_connect("mysql, martin"); mysql_select_db("martin"); $date=date("Y-m-d"); /* Get the current date in the right SQL format */ $sql="INSERT INTO students VALUES(NULL,' . $_POST[f_name"] . "',' . $_POST["l_name"] . "', . $_POST["student_id"] . ",' . $_POST["email"] . "',' . $date . "', . $_POST["gr"] . ")"; /* construct the query */ mysql_query($sql); mysql_close(); /* execute the query */ echo"<h3>Thank you. The data has been entered.</h3> \n"; echo'<p><a href="data_in.php">Back to registration</a></p> . \n; echo'<p><a href="data_out.php">View the student lists</a></p> .\n; } Student Database: data_in.php else { ?> <h3>Enter your items into the database<...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

East Los Angeles College - COMP - 202
Learning outcomes COMP202 Complexity of Algorithms Sorting [See Sections 2.4, 4.1, 4.3, and 4.5 in Goodrich and Tamassia.]1. Understand the sorting problem, and its fundamental importance in algorithms. 2. Have a wide knowledge of different types o
East Los Angeles College - COMP - 519
COMP519: Web Programming Autumn 2008PHP Basics: Introduction to PHP a PHP file, PHP workings, running PHP. Basic PHP syntax variables, operators, if.else.and switch, while, do while, and for. Some useful PHP functions How to work with HTML fo
East Los Angeles College - COMP - 519
DatamodelsXML: eXtensible Markup LanguageSlides are based on slides from Database System Concepts Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-use Many examples are from www.w3schools.comRDBMS: atomic elements store
East Los Angeles College - COMP - 519
Comp 519: Web Programming Autumn 2008Advanced SQL and PHP Advanced queries Querying more than one table Searching tables to find information Aliasing tables PHP functions for using query resultsUsing several tables mySQL (like any other database
Sveriges lantbruksuniversitet - GEOG - 420
2/20/2009GEOG 420 Lecture 5 feminismsOutline feminist cultural geographiesFeminist cultural geographiesfeminismsSex: biologically male or female Gender: social rendering (e.g. inscription, identification, and enactment) of male and fema
Sveriges lantbruksuniversitet - GEOG - 420
1/16/2009GEOG 420 Lecture 1Outline Environmental determinism Carl Sauer &amp; landscapeOld Cultural Geography The superorganic Important to understand how culture has been used and why it has been used in certain ways History of geography i
Sveriges lantbruksuniversitet - GEOG - 420
1/23/2009GEOG 420 Lecture 2Outline 20th C. human geographies cultural studiesnew cultural geography new cultural geographyspace Late 19th C. and early 20th C. geography explored, identified, described, mapped, classified (Sauer, Hartsho
Sveriges lantbruksuniversitet - GEOG - 420
2/6/2009GEOG 420 Lecture 4 social theoryOutline globalization of capitalism Don Mitchells critiqueMarxist critiquessocial theoryUKCommittee on SOCIAL THEORY The University of Kentucky's Committee on Social Theory was formed in 1989 to
Sveriges lantbruksuniversitet - GEOG - 102
Lect. 4 GEOG 102 Sep. 26, `07 Hertzman1) Comments on Ronald Wright's conclusions 2) Urban heat islands-myths and facts 3) Cities of the Less Developed World &amp; Related Issues1a) Comments on Ronald Wright's conclusionsa) pp. 128-29 RUNAWAY TRAIN i
East Los Angeles College - COMP - 103
CPU Registers in PentiumComputer Systems Lecture 9CPU status flags EFLAG: The Flag register holds the CPU status flags The status flags are separate bits in EFLAG where information on important arising conditions such as overflow, or carry bits
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 4. MORE ON BASIC DATA TYPES1) Pointers 2) Type declarations 3) Access/reference values 4) Type renaming/aliasing 5) Subtypes 6) Macro substitutionPOINTERS Pointer variables have as their value an address, i.e. a refer
East Los Angeles College - COMP - 317
Exponentialsc := 1 ; while b &gt; 0 c := 1 ; while b &gt; 0 while (b a := b := b := b c := c * { c=mn }The Goal{ a=m b=n b 0 }while (b div 2) * 2 = b a := a * a ; b := b div 2 b := b 1 ; c := c * adiv 2) * 2 = b a * a ; b div 2 1 ; aThe Invar
East Los Angeles College - COMP - 205
COMP205 Comparative Programming LanguagesPart 1: Introduction to programming languagesLecture 3: Managing and reducing complexity, program processingMANAGING AND REDUCING COMPLEXITY, AND PROGRAM PROCESSING1. Managing and reducing complexity
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES INTRODUCTION1) Definition2) Note on structured and modular programming, and information hiding 3) Example imperative languages 4) Features of imperative languages(Q) WHAT IS AN IMPERATIVE LANGUAGE? We can define such
East Los Angeles College - COMP - 213
COMP213 Example Exam: Model Solution 1. (a) import java.util.Vector; /* * Trees with integer internal labels and lists of subtrees. * * The {@link TreeNode list of subtrees} is implemented as a linked list. * * @author &lt;a href=&quot;mailto:grant@liverpool
East Los Angeles College - COMP - 213
COMP213DEPARTMENT : Computer ScienceSEPTEMBER 2005 EXAMINATIONSBachelor of Arts : Year 2 Bachelor of Arts : Year 3 Bachelor of Engineering : Year 2 Bachelor of Science : Year 1 Bachelor of Science : Year 2Advanced Object-Oriented Programming
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 5. COMPOUND (HIGHER LEVEL) DATA TYPES I - ARRAYS1) Introduction to higher level types 2) Arrays and their declaration 3) Assigning values to array elements 4) Operations on arrays 5) Ada array attributesINTRODUCTION TO
East Los Angeles College - COMP - 205
Comp 205:Comparative Programming LanguagesDeclarative Programming Languages Logic Programming Horn-Clause Logic PrologLecture notes, exercises, etc., can be found at: www.csc.liv.ac. uk/~grant/Teaching/COMP205/Declarative vs ImperativeDecla
Sveriges lantbruksuniversitet - PHYS - 101
CHAPTER 3: Kinematics in Two or Three Dimensions; Vectors46. Choose the origin to be at ground level, under the place where the projectile is launched, and upwards to be the positive y direction. For the projectile, v0 = 65.0 m s , 0 = 35.0, a y =
Sveriges lantbruksuniversitet - PHYS - 1010901
CHAPTER 3: Kinematics in Two or Three Dimensions; Vectors46. Choose the origin to be at ground level, under the place where the projectile is launched, and upwards to be the positive y direction. For the projectile, v0 = 65.0 m s , 0 = 35.0, a y =
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 12a. ERROR HANDLING1) Causes of errors 2) Classification of errors 3) Signals and exceptionsCAUSES OF ERRORS1) Domain/data errors: an operation is called with data that cannot be handled by that operation, e.g. divide
Sveriges lantbruksuniversitet - COGS - 300
Some material relevant to the Syllogism.First, we should get straight on the four &quot;categorical forms&quot; of statements. They are: A: E: I: O: All X are Y No X are Y Some X are Y Some X are not YThe A, E, I, O are the standard names for the type of st
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 11. PROGRAM CONSTRUCTS 2 (REPETITION)REPETITION Two main forms of repetition: 1) Fixed Count Loops: Repetition over a finite set (for loops). 2) Variable Count Loops: Repetition as long as a given condition holds (whil
East Los Angeles College - COMP - 205
Comp 205:Comparative Programming LanguagesFunctional Programming Languages:T A R L e i s c t u c r s o m i v e p d r e e h f i n e n i t i o s i o n n s s M h e t y p e o f l i s t s i sRecursion r e c u r s i v e l y d e f i n e d :More
East Los Angeles College - COMP - 205
Comp 205:Comparative Programming LanguagesE eErrorsr r o v a l ur s aa t er e s areported w h x n i l l e g a l ee pn r e st h se i o nH :askel li nt er pr et erLazy Evaluation E E I n vr r o a
East Los Angeles College - COMP - 213
COMP 213Advanced Object-oriented ProgrammingLecture 13Propositional Logic(Mondrian )TaskDevelop a program that: allows a user to enter a string representing a term in propositional logic; prints out the term with minimal and maximal bracke
East Los Angeles College - COMP - 205
k y {w } z xwv C #8} w8 D8~&amp;d {| w y D% B 9jSP WQ P FP QuCDPdg 9PfgYpP Q j%5 DeuC 6I#DED5B @85641 Q A BC S A A 9 F B C A97 3 k 94%IDB t 9 P9 BY6m Clengths = map (length) incAll = map (plus 1) where plus m n = m + n # kH l 44 Q %4%3 D4Pd Tr D 9 D
East Los Angeles College - COMP - 213
COMP213DEPARTMENT : Computer ScienceSEPTEMBER 2004 EXAMINATIONSBachelor of Arts : Year 2 Bachelor of Arts : Year 3 Bachelor of Engineering : Year 2 Bachelor of Science : Year 1 Bachelor of Science : Year 2Advanced Object-Oriented Programming
East Los Angeles College - COMP - 213
COMP 213Advanced Object-oriented ProgrammingLecture 5ScopeClassesA class contains declarations of members. Members can be: fields (including constants) methods classes Each of these has a name, as do classes themselves. Every name has a scop
East Los Angeles College - COMP - 205
COMP205 Comparative Programming LanguagesGrant Malcolm (grant@csc.liv.ac.uk) Introduction to programming languages The imperative paradigm The functional paradigm Other paradigms and concluding remarksBOOKS1. Tucker, A. and Noonan, R. Program
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 9. EXPRESSIONS AND STATEMENTS1. Unions 2.Expressions. 3.Operators. 4.Type equivalence. 5.Coercion, casting and conversion.UNIONS It is sometimes desirable to define a variable which can be of two or more different typ
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 6. COMPOUND (HIGHER LEVEL) DATA TYPES II - MORE ON ARRAYS1) Constrained (static) and unconstrained (dynamic) arrays. 2) Flexible arrays 3) Multi-dimensional arrays 4) Arrays of arrays 5) Lists, sets, bags,Etc. 6) Strings
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 14. PROGRAM COMPOSITION II1) More on parameter passing: a) Parameter association b) Default parameters c) Procedures as parameters 2) Modules: Ada packages, C modules, C header files 3) Programs 4) Generics and Abstract
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 2. DATA1) Data Attributes2) Declarations, Assignment and Instantiation 3) Global and Local Data 4) Variables 5) Constants 6) Example programsDATA - &quot;that which is given&quot;A data item has a number of attributes: 1) An A
Cal Poly - MEC - 6304
PERFORMANCE 23 18SWASHPLATESERIES PUMP ANGLETHESE CURVES DO NOT TAKE LOSSES DUE TO THE, CHARGEINTO PUMPACCOUNT
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 3. DATA AND DATA TYPES1) Data Review 2) Anonymous Data Items 3) Renaming 4) Overloading 5) Introduction to Data Types 6) Basic types 7) Range and precision 8) Ada/Pascal &quot;attributes&quot;ANONYMOUS DATA ITEMS Often we use d
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 5. COMPOUND (HIGHER LEVEL) DATA TYPES I - ARRAYS1) Introduction to higher level types 2) Arrays and their declaration 3) Assigning values to array elements 4) Operations on arrays 5) Ada array attributesINTRODUCTION TO
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 6. COMPOUND (HIGHER LEVEL) DATA TYPES II - MORE ON ARRAYS1) Constrained (static) and unconstrained (dynamic) arrays. 2) Flexible arrays 3) Multi-dimensional arrays 4) Arrays of arrays 5) Lists, sets, bags,Etc. 6) Strings
East Los Angeles College - COMP - 205
COMP205 Comparative Programming LanguagesGrant Malcolm (grant@csc.liv.ac.uk) Introduction to programming languages The imperative paradigm The functional paradigm Other paradigms and concluding remarksBOOKS1. Tucker, A. and Noonan, R. Program
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 11. PROGRAM CONSTRUCTS 2 (REPETITION)1) Fixed count loops 2) Variable count loops 3) Post-test Loops 4) Terminating a loopREPETITION Two main forms of repetition: 1) Fixed Count Loops: Repetition over a finite set (fo
Sveriges lantbruksuniversitet - M - 251
Homework #1 MATH 251 Coordinates in Three Dimensions a) Describe the geometry of the set of points whose coordinates (x, y, z) satisfy the equation: x2 + y 2 + z 2 + 4x + 2y 6z 22 = 0 . b) Show that the intersection of the object in part a) with
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 7. COMPOUND (HIGHER LEVEL) DATA TYPES III1) Enumerated types 2) 3) 4) 5) 6) Records and structures Accessing fields in records/structures Operations on records/structures Variant records Dynamic and static arrays of reco
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 9. EXPRESSIONS AND STATEMENTS1. Unions 2.Expressions. 3.Operators. 4.Type equivalence. 5.Coercion, casting and conversion.UNIONS It is sometimes desirable to define a variable which can be of two or more different typ
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 12a. ERROR HANDLING1) Causes of errors 2) Classification of errors 3) Signals and exceptions12b. PROGRAM COMPOSITION I1) Program hierarchy 2) Blocks 3) Routines 4) Procedures and functionsCAUSES OF ERRORS1) Domain/
Sveriges lantbruksuniversitet - MATH - 443
MATH 443 Assignment #7Below are short answers (hints) to assigned questions.19A(i) There are 6 = 15 points in the incidence structure. Consider two 2 distinct edges of K6 . If they have a common endpoint, they belong to a unique triangle, and to
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES INTRODUCTION1) Definition2) Note on structured and modular programming, and information hiding 3) Example imperative languages 4) Features of imperative languages(Q) WHAT IS AN IMPERATIVE LANGUAGE? We can define such
East Los Angeles College - COMP - 205
COMP205 Comparative Programming LanguagesPart 1: Introduction to programming languagesLecture 3: Managing and reducing complexity, program processingMANAGING AND REDUCING COMPLEXITY, AND PROGRAM PROCESSING1. Managing and reducing complexity
East Los Angeles College - COMP - 205
TYPE EQUIVALENCE1) Coercion 2) Casting 3) ConversionCOERCION Operators require their operands to be of a certain type (similarly expressions require their arguments to be of the same type). In some cases it may be appropriate, when a compiler fi
Sveriges lantbruksuniversitet - MATH - 202
MACM 202 Assignment 3, Spring 2004Luis Goddyn and Michael MonaganThis assignment is worth 10% of your grade. It is due Friday February 18th at beginning of class. A late penalty of 20% will apply for each day late. Do question: Either 1 or 2 , eith
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 4. MORE ON BASIC DATA TYPES1) Pointers 2) Type declarations 3) Access/reference values 4) Type renaming/aliasing 5) Subtypes 6) Macro substitutionPOINTERS Pointer variables have as their value an address, i.e. a refer
East Los Angeles College - COMP - 205
COMP205 IMPERATIVE LANGUAGES 13. PROGRAM COMPOSITION II1) Scope a] Ada scope rules b] C scope rules 2) Parameter passing a] Ada parameter modes b) Parameter passing mechanismsSCOPE RULES Scope rules govern the visibility and life time of data ite
Sveriges lantbruksuniversitet - MATH - 443
MATH 443 - Assignment #3Below are short answers (hints) to assigned questions.14EFix one edge, say e, of the convex (n + 1)-gon. For any particular dissection into quadrilaterals consider the quadrilateral &quot;supported&quot; by edge e. The remaining thr
East Los Angeles College - COMP - 205
Comp 205:Comparative Programming Languages FunctionalProgrammingLanguages:MoreLists Recursivedefinitions Listcomprehensions Lecturenotes,exercises,etc.,canbefoundat: www.csc.liv.ac.uk/~grant/Teaching/COMP205/RecursionThetypeoflistsisrecursive
Sveriges lantbruksuniversitet - MATH - 820
TSP Lower BoundsLuis Goddyn, Math 408 We give here two techniques for obtaining lower bounds on TSP instances. That is, for a given instance (V, d), we would like to find the largest possible number t such that (T ) t for every TSP tour T . We firs
Sveriges lantbruksuniversitet - MATH - 445
A SAMPLE MATH DOCUMENTJOHN DOE, MATH 445, FALL 2006This is a sample input le. Comparing it with the output it generates can show you how to produce a simple document of your own. 1. Ordinary Text The ends of words and sentences are marked by space
Sveriges lantbruksuniversitet - MATH - 820
TSP HeuristicsLuis Goddyn, Math 408 There are two types of heuristic methods for finding optimal TSP tours. Scratch methods produce an initial tour which is hopefully fairly close (say 10%) from being optimal. Improvement methods (sometimes called p
Sveriges lantbruksuniversitet - MATH - 445
Homework 7 SolutionsOuterplanar A graph G is outerplanar if it can be drawn in the plane so that all vertices lie on the infinite face. 1. Show that G is outerplanar if and only if G has no K2,3 or K4 minor. Solution: Let G+ be the graph obtained fr
Sveriges lantbruksuniversitet - MATH - 820
Exercises for Math 820 Luis Goddyn 1. Let w : V {0, 1, 2, . . .} be a weighting of the vertices of an undirected graph G = (V, E). Describe an algorithm which either nds an orientation of G for which each vertex v has out-degree exactly + (v) = w(v
Sveriges lantbruksuniversitet - MATH - 443
MATH 443 - Assignment #5Below are short answers (hints) to assigned questions.37ALet C denote the group of rotations of the cube. Following the description of elements of C in Appendix 1 we find that the cycle index of the action of C on the six
Sveriges lantbruksuniversitet - MATH - 445
Higher Surfaces I: embeddings and the torusIn this section, graphs are permitted to have loops and parallel edges. Surface: A surface is a topological space which appears locally like the plane. More precisely, for every point x in the surface, ther
Sveriges lantbruksuniversitet - MATH - 445
Extremal Graph Theory II: more Ramsey TheoryIn this section, graphs are assumed to have no loops or parallel edges. Hypergraph: A hypergraph H consists of a set of vertices, denoted V (H), a set of edges (sometimes called hyperedges), denoted E(H),