-
Notifications
You must be signed in to change notification settings - Fork 0
Database
To perform directly through the following syntax:
- SELECT [COLUMN1, COLUMN2... OR * for ALL Columns] FROM [TABLE_NAME];
To select for specific criteria use the following syntax
- SELECT [COLUMN1, COLUMN2... OR * for ALL Columns] FROM [TABLE_NAME] WHERE [BOOLEAN STATEMENT*];
To group by a specific criteria use the following syntax
- SELECT [COLUMN1, COLUMN2... OR * for ALL Columns] FROM [TABLE_NAME] GROUP BY [COLUMN];
To order the query results in ascending or descending order use the following syntax:
- SELECT [COLUMN1, COLUMN2... OR * for ALL Columns] FROM [TABLE_NAME] ORDER BY [COLUMN] AESC/DESC*
NOTES: These queries are not mutually exclusive from one another and can be combined to create more specific queries.
Sample Boolean statement:
x = y, x > y, x < y
boolean operators include
AND, OR, NOT, LIKE
By default order by sorts elements in ascending order so AESC is not strictly necessary, however to order by descending order DESC is necessary.
For more specific SQL Queries such as those that use JOIN see here
To perform insertions into the database use the following syntax:
INSERT INTO [TABLE_NAME], (COLUMN1, COLUMN2, ... ) VALUES (VALUE1, VALUE2, ...);
To perform multiple insertions use similar syntax as follows:
INSERT INTO [TABLE_NAME], (COLUMN1, COLUMN2, ... ) VALUES (VALUE1, VALUE2, ...), (VALUE3, VALUE4, ...), ... ;
Notes:
the values must coincide with the listed columns for example you cant insert more values than there are columns nor can you insert a string value into a column that accepts all integers.
some columns have a constraints such that they cannot be null meaning an insertion cannot omit these columns.
To remove items from a database use the following syntax:
DELETE FROM [TABLE] WHERE [BOOLEAN STATEMENT];
Notes:
the omission of the conditional statement results in the removal of all items from the table.
- Table
- denotes information for table number
- must include information of table availability and a unique identifier for each table
- this table can be viewed by the hostess position of a restaurant, as well as the manager
- orders associated with each Table are given the table id as part of the foreign key