0% found this document useful (0 votes)
54 views

Compound Condition

SQL is a language for querying and managing relational databases. It allows users to create tables, insert records, and query data using commands like SELECT, INSERT, UPDATE, DELETE. Tables can be joined and their data restricted using WHERE clauses. Aggregate functions like COUNT, SUM, AVG can perform calculations on table columns. Views give users customized perspectives of the database, while indexes improve query performance. Referential integrity ensures relationships between tables are maintained through foreign keys.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Compound Condition

SQL is a language for querying and managing relational databases. It allows users to create tables, insert records, and query data using commands like SELECT, INSERT, UPDATE, DELETE. Tables can be joined and their data restricted using WHERE clauses. Aggregate functions like COUNT, SUM, AVG can perform calculations on table columns. Views give users customized perspectives of the database, while indexes improve query performance. Referential integrity ensures relationships between tables are maintained through foreign keys.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL (Structured Query Language)-Allows users to query a relational database MySQL-Premiere script provided with the Data Files

for this text will: Activate the database,Create the tables,Insert the records To run a script in MySQL: Type the SOURCE command followed by the name of the file,Press the Enter key The most recent command entered in MySQL is stored in a special area of memory called the statement history SQL CREATE TABLE command-Creates a table by describing its layout Typical restrictions placed on table and column names by DBMS Names cannot exceed 18 characters-Names must start with a letter Names can contain only letters, numbers, and underscores (_)-Names cannot contain spaces Simple condition: field name, a comparison operator, and either another field name or a value

Compound condition Connecting two or more simple conditions using one or both of the following operators: AND and OR Preceding a condition by NOT operator-Reverses the truth or falsity of the original condition BETWEEN operator-Value must be between the listed numbers Connecting simple conditions using AND operator All of the simple conditions must be true for the compound condition to be true Connecting simple conditions using OR operator Any of the simple conditions must be true for the compound condition to be true Sort data using the ORDER BY clause Sort key: field on which to sort data When sorting data on two fields: Major sort key (or primary sort key): more important sort key Minor sort key (or secondary sort key): less important sort key (sort minor sort key by records with same major sort key, see Fig 3-33 in next slide) Built-in functions (aggregate functions) in SQL COUNT: calculates number of entries in the table COUNT(*): to select any column in the table. SUM or AVG: calculates sum or average of all entries in a given column MAX or MIN: calculates largest or smallest values respectively Subquery: inner query Outer query is evaluated after the subquery GROUP BY clause indicates grouping in SQL HAVING clause is to groups what the WHERE clause is to rows Union of two tables is a table containing all rows in the first table, the second table, or both tables Two tables involved must be union compatible Same number of fields Corresponding fields must have same data types To join tables, construct the SQL command as: SELECT clause: list all fields you want to display FROM clause: list all tables involved in the query WHERE clause: give the condition that will restrict the data to be retrieved to only those rows from the two tables that match MySQL Create the new table using a CREATE TABLE command Use an INSERT command to insert the appropriate data into the new table

Joining tables: use a condition that relates matching rows in the tables to be joined Built-in (aggregate) functions: COUNT, SUM, AVG, MAX, and MIN One SQL query can be placed inside another; the subquery is evaluated first UNION operator: unifies the results of two queries Calculated fields: include the calculation, the word AS, the name of the calculated field INSERT command adds a new row to a table UPDATE command changes existing data DELETE command deletes records INTO clause is used in a SELECT command to create a table containing the results of the query Views give each user his or her own view of the data in a database Indexes facilitate data retrieval from the database Security is provided in SQL systems using the GRANT and REVOKE commands Entity integrity: no field that is part of the primary key can accept null values Referential integrity: value in any foreign key field must be null or must match an actual value in the primary key field of another table Legal-values integrity: value entered in a field must be one of the legal values that satisfies some particular condition ALTER TABLE command allows you to add fields to a table, delete fields, or change the characteristics of fields In Access, change the structure of a table by making the changes in the table design DROP TABLE command lets you delete a table from a database In Access, delete a table by selecting the Delete command on the tables shortcut menu in the Navigation Pane System catalog stores information about the structure of a database Stored procedure: query saved in a file that users can execute later Trigger: action that occurs automatically in response to an associated database operation such as an INSERT, UPDATE, or DELETE Delimiter: semicolon at the end of a MySQL command Client/server system Database resides on a computer called the server Client Computer connected to a network Has access through server to the database Sysindexes: information about indexes Sysviews: information about views Documenter: allows user to print detailed documentation about any table, query, report, form, or other object in the database Systables: information about the tables known to SQL Syscolumns: information about the columns or fields within these tables Legal-Values Integrity Validation rule: must be followed by data entered Validation text: informs user of the reason for rejection of data that violates the rule CHECK clause enforces legal-values integrity Foreign key: field(s) whose value is required to match the value of the primary key for a second table Referential integrity: if table A contains a foreign key that matches the primary key of table B, the values of this foreign key must match the value of the primary key for some row in table B or be null Security-Prevention of unauthorized access to database Database administrator determines types of access various users can have SQL security mechanisms GRANT: provides privileges to users-GRANT SELECT ON Customer TO Jones ; REVOKE: removes privileges from users-REVOKE SELECT ON Customer FROM Jones Indexs-Single-field index Key is a single fieldAlso called a single-column index Multiple-field index More than one key fieldAlso called a multiple-column index

You might also like