23.10.2012 Views

Structured Query Language (SQL) - Cultural View of Technology

Structured Query Language (SQL) - Cultural View of Technology

Structured Query Language (SQL) - Cultural View of Technology

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table (database) 109<br />

An equally valid representations <strong>of</strong> a relation is as an n-dimensional chart, where n is the number <strong>of</strong> attributes (a<br />

table's columns). For example, a relation with two attributes and three values can be represented as a table with two<br />

columns and three rows, or as a two-dimensional graph with three points. The table and graph representations are<br />

only equivalent if the ordering <strong>of</strong> rows is not significant, and the table has no duplicate rows.<br />

See also<br />

• Relation (database)<br />

• Table (information)<br />

Transact-<strong>SQL</strong><br />

Transact-<strong>SQL</strong> (T-<strong>SQL</strong>) is Micros<strong>of</strong>t's and Sybase's proprietary extension to <strong>SQL</strong>. Transact-<strong>SQL</strong> is central to using<br />

<strong>SQL</strong> Server. All applications that communicate with an instance <strong>of</strong> <strong>SQL</strong> Server do so by sending Transact-<strong>SQL</strong><br />

statements to the server, regardless <strong>of</strong> the user interface <strong>of</strong> the application.<br />

Transact-<strong>SQL</strong> augments <strong>SQL</strong> with certain additional features:<br />

• Control-<strong>of</strong>-flow language<br />

• Local variables<br />

• Various support functions for string processing, date processing, mathematics, etc.<br />

• Changes to DELETE and UPDATE statements<br />

These additional features make Transact-<strong>SQL</strong> Turing complete.<br />

Flow control<br />

Keywords for flow control in Transact-<strong>SQL</strong> include BEGIN and END, BREAK, CONTINUE, GOTO, IF and ELSE,<br />

RETURN, WAITFOR, and WHILE.<br />

IF and ELSE allow conditional execution. This batch statement will print "It is the weekend" if the current date is a<br />

weekend day, or "It is a weekday" if the current date is a weekday.<br />

IF DATEPART(dw, GETDATE()) = 7 OR DATEPART(dw, GETDATE()) = 1<br />

ELSE<br />

PRINT 'It is the weekend.'<br />

PRINT 'It is a weekday.'<br />

BEGIN and END mark a block <strong>of</strong> statements. If more than one statement is to be controlled by the conditional in the<br />

example above, we can use BEGIN and END like this:<br />

IF DATEPART(dw, GETDATE()) = 7 OR DATEPART(dw, GETDATE()) = 1<br />

BEGIN<br />

END<br />

ELSE<br />

BEGIN<br />

END<br />

PRINT 'It is the weekend.'<br />

PRINT 'Get some rest!'<br />

PRINT 'It is a weekday.'<br />

PRINT 'Get to work!'

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!