Preview

Sql basics

Good Essays
Open Document
Open Document
584 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Sql basics
reference: http://www.tutorialspoint.com/sql

important: constrains:

SQL constraints are used to specify rules for the data in a table.
If there is any violation between the constraint and the data action, the action is aborted by the constraint.

In SQL, we have the following constraints:

NOT NULL - Indicates that a column cannot store NULL value
UNIQUE - Ensures that each rows for a column must have a unique value
PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Ensures that a column (or combination of two or more columns) have an unique identity which helps to find a particular record in a table more easily and quickly
FOREIGN KEY - Ensure the referential integrity of the data in one table to match values in another table
CHECK - Ensures that the value in a column meets a specific condition
DEFAULT - Specifies a default value when specified none for this column

---------------------------------------
Select statement:

Slecet From Where Order by [DESC/ASC] group by COUNT/SUM

--------------------------------------
Join Keyword:

what is spurious tuple?

A spurious tuple is, basically, a record in a database that gets created when two tables are joined badly. In database-ese, spurious tuples are created when two tables are joined on attributes that are neither primary keys nor foreign keys.

---------------------------------------
CROSS JOIN (avoid to use):

The SQL CROSS JOIN produces a result set which is the number of rows in the first table multiplied by the number of rows in the second table, if no WHERE clause is used along with CROSS JOIN. This kind of result is called as Cartesian
Product.

Select *
FROM table1
CROSS JOIN table2;

---------------------------------------
Full OUTER JOIN:
The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the right table (table2).The FULL OUTER JOIN keyword combines the result of

You May Also Find These Documents Helpful

  • Satisfactory Essays

    PT2520 Unit7Labs Tramil

    • 330 Words
    • 1 Page

    13. What is referential integrity? Exists when every foreign key relates to an existing primary key. There are no orphan records in child tables that have no reference in a parent table.…

    • 330 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    It203 Homework 5

    • 319 Words
    • 2 Pages

    Once the tables are created and the relationship is established, the data can be entered. In general, data can be placed in tables containing foreign keys only after the data is entered into the tables that they reference. This restriction means that data must be inserted first into the MEMBER table. If not, the data for the VISIT table will be rejected for the referential integrity…

    • 319 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The column specification that determines what kind of data can be stored in that column, character versus numeric or date, for example.…

    • 327 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Kudler Fine Food Week 4

    • 284 Words
    • 2 Pages

    Note: Select all of the data from both of your tables before you perform the following.…

    • 284 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    3. Why do you think cross joins are allowed as a legitimate join? What uses can you see for joins?…

    • 337 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    • Develop at least two tables, using the same step of the accounting cycle selected for your previous Learning Team assignments, that could be used in a database for your selected accounting cycle.…

    • 103 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Anime LIst

    • 11441 Words
    • 52 Pages

    A unique identifier for a data row that consists of more than one field is commonly…

    • 11441 Words
    • 52 Pages
    Good Essays
  • Good Essays

    research

    • 995 Words
    • 4 Pages

    When you include multiple data sources in a query, you use joins to limit the records that you want to see, based on how the data sources are related to each other. You also use joins to combine records from both data sources, so that each pair of records from the sources…

    • 995 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Data Integrity

    • 500 Words
    • 3 Pages

    This section describes the rules that can be applied to table columns to enforce different types of data integrity.…

    • 500 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The SQL SELECT statement is used to retrieve records from one or more tables in your SQL database.សេចក្តីថ្លែងការណ៍ SQL ដែលបានជ្រើសត្រូវបាន ប្រើដើម្បីទាញយកកំណត់ត្រា ពីតា រាង មួ យឬ ច្រើននៅក្នុងមូលដ្ឋានទិន្នន័យ SQL របស់អ្នក។…

    • 1831 Words
    • 11 Pages
    Satisfactory Essays
  • Good Essays

    The unique data field in a table is assigned a primary key. The primary key helps in the identification of data. It also checks for duplicates within the same table, thereby reducing data redundancy. There are tables, which have a secondary key in addition to the primary key. The secondary key is also called 'foreign key'. The secondary key refers to the primary key of another table, thus establishing a relationship between the two tables.…

    • 686 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    dbms notes

    • 2145 Words
    • 23 Pages

    SELECT:- The select clause is used to list the attributes desired in the result of a query. It corresponds to the projection operation of the relational algebra.…

    • 2145 Words
    • 23 Pages
    Powerful Essays
  • Good Essays

    DATABASE SQL

    • 592 Words
    • 2 Pages

    SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS).…

    • 592 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Tableau Notes

    • 257 Words
    • 2 Pages

    - Use join if you are using two different tables from same database or data warehouse…

    • 257 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Data Base Queries

    • 2279 Words
    • 10 Pages

    "Group Functions" also known as "Multiple-Row Functions". They operates on set of rows to give one result per group. These set may be the whole table or the table split into groups.…

    • 2279 Words
    • 10 Pages
    Powerful Essays