1 - Review of Fundamentals of DBMS
1 - Review of Fundamentals of DBMS
Foreign Key
Implements 1:N relationship
between customer and order
•CREATE
• Creates an object (a table, for example) in the database.
•DROP
• Deletes an object in a database, usually irretrievably.
•ALTER
• Modifies the structure of an existing object in various ways.
For example, adding a column in an existing table.
• Commands used to maintain and query a database,
including those for updating, inserting, modifying, and
querying data.
• They may be issued so that a result is returned
immediately following the execution of the
statement.
The acronym CRUD refers to all major functions that need to be
implemented.
SYNTAX
SELECT columnlist FROM tablename;
• The columnlist represents one or more attributes, separated by
commas.
• An asterisk (*) can be used as a wildcard character to list ALL
attributes.
• The UPDATE command is used to modify data in a table.
SYNTAX
UPDATE tablename
SET columnname = expression
WHERE conditionlist;
• The DELETE command deletes a table row.
SYNTAX
DELETE FROM tablename
WHERE conditionlist;
• If WHERE condition is not specified, ALL rows from specified
table will be deleted.
• PRIMARY KEY – a key that uniquely identifies each record in
a table and it should not contain NULL values.
SYNTAX
CREATE TABLE tablename (
columnname1 datatype,
…,
PRIMARY KEY(columnname));
• FOREIGN KEY – a key used to link two tables together. It is
a field in one table that refers to the PRIMARY KEY in another
table.
SYNTAX
CREATE TABLE tablename (
columnname1 datatype,
…,
PRIMARY KEY(columnname),
FOREIGN KEY(columnname) REFERENCES
tablename(primary key));