Jump to content

Use SQL to create database structures and manipulate data

From Wikiversity
Web Design Use SQL to create database structures and manipulate data
This page is part of the Web Design project.
Original image: 'php' http://www.flickr.com/photos/29174632@N00/145023802 by: Raphael Goetter

From the official document ICAB4136A:

"This unit defines the competency required to use a structured query language (SQL) to define, create and manipulate database structures and associated data in a relational database."

Basically, that means ... (translate above into plain english)

You can read more about this unit on the National Training Information Systems Official document for ICAB4136A.

This unit forms part of the following qualifications:


How this unit will help you

[edit | edit source]

After learning and applying the skills required by this unit you'll be able to demonstrate your skills in:

ELEMENT PERFORMANCE CRITERIA
1. Write a simple SQL statement to retrieve and sort data
  1. Retrieve all the data from a single table
  2. Retrieve data from specific columns in a single table
  3. Use 'order by' to sort query output
2. Write an SQL statement that selectively retrieves data
  1. Restrict the number of rows retrieved by placing criteria in the 'where' clause
  2. Restrict the number of rows retrieved by placing specific criteria in the select statement
  3. Use comparison operators in the 'where' clause to compare numeric, character, string, date and time data
  4. Use Boolean operators with the correct precedence
  5. Use criteria in the 'where' clause to check for a range of values, to select values from a list, and to check for values that match a pattern
  6. Use SQL syntax to suppress duplicate values from query results
  7. Take action to exclude null values from a query result
3. Write SQL statements that use functions
  1. Use arithmetical operators with the correct precedence
  2. Use string functions and operators to obtain the required query output
  3. Use mathematical functions to obtain the required output, where required
  4. Use date functions to obtain the required output
  5. Use SQL aggregate functions to obtain the required output
4. Write SQL statements that use aggregation and filtering
  1. Use 'group by' to aggregate data by multiple columns
  2. Sort aggregated data in the query output
  3. Filter aggregated data using the 'having' clause
5. Write SQL statements that retrieve data from multiple tables
  1. Employ the inner join syntax to retrieve data from two or more tables
  2. Use 'left outer', 'right outer' and 'full outer' syntax to join tables in the select statement
  3. Use correct syntax in the 'where' clause to retrieve data from multiple tables
  4. Write a union query that retrieves data from more than one table
6. Write and execute SQL sub queries
  1. Construct single and nested sub-queries
  2. Construct sub-queries that return a single row, and multiple rows
  3. Use correlated sub-queries to retrieve required data
  4. Write sub-queries that use aggregates
7. Create and manipulate tables
  1. Identify required columns, data types, keys, relationships, indexes and constraints
  2. Use relevant naming conventions for all database elements
  3. Create tables that implement all required elements
  4. Insert rows into tables
  5. Update some or all of the data in a table
  6. Add columns to a table
  7. Modify a column within a table
  8. Delete a column from a table
  9. Delete rows from a table
  10. 0View detailed information regarding a table
  11. 1Delete tables with regard to referential integrity rules
8. Create and use views
  1. Create views that satisfy information requirements
  2. Use check constraints in a view
  3. Retrieve, insert, update and delete data using a view
  4. Drop a view from a database
9. Create and use stored procedures
  1. Create and execute stored procedures that use SQL to retrieve, insert or modify data according to information requirements
  2. Create and execute stored procedures that use one or more parameters
  3. Drop a stored procedure from the database
  4. Create and test database triggers that automate data management or perform specific required data-related functions
  • translate the above elements and performance criteria into plain English and summaries here...

To find the 2nd max salary from your table -

1> Select Top 1* 
   from table-name
   where salary < ( select max(salary) from table-name ); 

...

Ideas for demonstrating this unit

[edit | edit source]

The best way to demonstrate these skills is ...

Grading

[edit | edit source]

If you are demonstrating this unit as part of a formal course, you might find that the unit is graded (meaning you can not only demonstrate your competence, but can also gain a credit or distinction). Your facilitator may already have set criteria that your college uses. If not, here are some ideas for possible credit/distinction activities that you can discuss with your facilitator:

  • ...

Notes and discrepancies

[edit | edit source]
  • ...