Database Design Flashcards
DDL (Database Definition Language)
is a sublanguage of SQL that consists of a set of commands used to define the database, tables, indexes, keys, constraints, and other metadata that comprise a database schema
Schema
is a skeletal structure of the database that focuses on the tables and constraints without the data.
CREATE TABLE
creates a new table and defines its structure. The columns and data types are required. The Primary Key, Foreign Keys, and other constraints are typically included, but can be added later.
DROP TABLE
removes a table
ALTER TABLE
can change the structure of a table or add a constraint
Sequences
are incrementing numbers that are commonly used as Surrogate Primary Keys. Start at 0, unless given a starting value. Never stops incrementing.
Creating a Sequence manually:
Getting the next number manually:
CREATE SEQUENCE custom_seq; SELECT nextval('custom_seq');
DCL
Database Control Language
GRANT
REVOKE
Database Control Language
used to administer the database, users, and permissions.
GRANT
gives access to a specific action for a resource to a user.
REVOKE
removes access to specific action for a resource from a user.
Normalization
The process of improving a database design in steps, called forms of normalization
Normalization has 4 goals:
- arranging data into logical groupings such that each group describes a small part of the whole;
- minimizing the amount of duplicate data stored in a database;
- organizing the data such that, when you modify it, you make the change in only one place
- building a database in which you can access and manipulate the data quickly and efficiently without compromising the integrity of the data in storage.