Database Implementation Module 5 (DSS 5525)

Get Started. It's Free
or sign up with your email address
Rocket clouds
Database Implementation Module 5 (DSS 5525) by Mind Map: Database Implementation Module 5 (DSS 5525)

1. Additional Join Forms

1.1. Inner

1.1.1. SELECT FROM Table1 JOIN Table2 ON table1.colum = table2.column WHERE criteria ORDER BY column;

1.1.2. use alias to simplify

1.2. Outer

1.2.1. use to show all rows including those with out matching row

1.2.2. left - all rows in the left table will appear

1.2.3. right - all rows in the left table will appear

2. SQL Data Manipulation Language (DML)

2.1. INSERT

2.1.1. INSERT VALUES (insert one row at a time)

2.1.2. delete restricted - eg. Artist cannot be deleted if there is work for that person

2.1.3. insert: default policy -eg. on insert of artist, a default policy is to be used for finding an artist

2.1.4. Other version accepts SELECT statements to copy data in from other tables

2.2. UPDATE

2.2.1. similar to INSERT bulk

2.2.2. us with WHERE clause to specificy which rows

2.2.3. UPDATE MyTable SET (col1 = val1, col2 = val2, etc) WHERE this is true

2.3. DELETE

2.3.1. DELETE FROM MyTable WHERE this is true

3. SQL Data Definition Language (DDL)

3.1. CREATE TABLE

3.1.1. column name

3.1.2. data type

3.1.2.1. INTEGER

3.1.2.2. SMAILLINT

3.1.2.3. Decimal(p,q)

3.1.2.4. CHAR(m)

3.1.2.5. DATE

3.1.3. optional constraints

3.1.3.1. PRIMARY KEY

3.1.3.1.1. defines PK for the table

3.1.3.2. UNIQUE

3.1.3.2.1. indicates no repeated values for column

3.1.3.3. NULL/NOT NULL

3.1.3.3.1. indicates if values are required

3.1.3.3.2. primary key columns must be NOT NULL

3.1.3.3.3. candidate keys can be either

3.1.3.4. FOREIGN KEY

3.1.3.4.1. defines referential integrity constraints

3.1.3.4.2. clauses

3.1.3.5. CHECK

3.1.3.5.1. defines data constraints

3.1.3.5.2. IN keyword provides the list

3.1.3.5.3. LIKE keyword

3.1.3.5.4. eg. CONSTRAINT NationalityValues CHECK (Nationality NI ("Canadian', English', etc.)

3.1.3.6. format

3.1.3.6.1. CONSTRAINT

3.1.3.6.2. constraint name (eg. ArtistPK)

3.1.3.6.3. the constraint (eg. PRIMARY KEY)

3.1.3.6.4. the column(s) in parens eg. PRIMARY KEY(ArtistID)

3.1.3.6.5. CONSTRAINT ArtistPK PRIMARY KEY(ArtistID)

3.1.3.7. special constraints

3.1.3.7.1. INTRArelation constraint

3.1.3.7.2. INTERrealtion constraint

3.1.4. other

3.1.4.1. DEFAULT

3.1.4.1.1. a keyword, not constraint

3.1.4.2. populate surrogate keys

3.1.4.2.1. INDENTITY ({start value},{increment value} - SQL Server

3.1.4.2.2. SEQUENCE - Oracle

3.1.5. typical restrictions

3.1.5.1. name no longer than 18 characters

3.1.5.2. name must start with a letter

3.1.5.3. name can contain letters, numbers, underscores

3.1.5.4. name cannot contain spaces

3.1.6. implementing cardinalities

3.1.6.1. 1:N, parent optional

3.1.6.1.1. specify FOREIGN KEY constraint

3.1.6.1.2. specify foreign key NULL

3.1.6.2. 1:N, parent required

3.1.6.2.1. specify FOREIGN KEY constraint

3.1.6.2.2. Set foreign key UNIQUE constraint

3.1.6.2.3. Set foreign key NULL

3.1.6.3. 1:1, parent optional

3.1.6.3.1. specify FOREIGN KEY constraint

3.1.6.3.2. specify foreign key UNIQUE constraint

3.1.6.3.3. set foreignkey NULL

3.1.6.4. 1:1, parent required

3.1.6.4.1. specify FOREIGN KEY constraint

3.1.6.4.2. specify foreign key UNIQUE constraint

3.1.6.4.3. set foreign key NOT NULL

3.1.6.5. casual relationship

3.1.6.5.1. create a foreign key

3.1.6.5.2. do not specify FOREIGN KEY constraint

3.1.6.5.3. if 1:1, specify foreign key UNIQUE

3.2. ALTER TABLE

3.2.1. add, remove, change columns and constraints

3.2.2. ON UPDATE CASCADE (or NO ACTION)

3.2.3. ON DELETE CASCADE (or NO ACTION)

3.2.4. ALTER TABLE MyTable ADD MyColumn....

3.2.5. ALTER TABLE MyTable DROP COLUMN MyColumn

3.3. DROP TABLE

3.3.1. deletes all data and the structure

3.3.2. will not drop a table that is a parent in a 1:N, in a FOREIGN KEY constraint

3.3.2.1. must drop constraints first

4. database design process

4.1. 1) Information-level design

4.1.1. user requirements

4.1.1.1. functional requirements

4.1.1.1.1. reports to be produced

4.1.1.1.2. inquiries to be supported

4.1.1.1.3. outputs sent to other systems

4.1.1.1.4. update transactions

4.1.1.1.5. calculations to be performed

4.1.1.1.6. restrictions to enforce

4.1.1.1.7. synonyms used for each attribute

4.1.1.2. physical constraints

4.1.1.2.1. volume measures

4.1.1.2.2. performance measures

4.1.1.2.3. examples

4.1.2. goals

4.1.2.1. complete

4.1.2.2. design should enforce requirements - not force programs

4.1.2.3. 3NF or 4NF

4.1.2.4. List of requirements the program will enforce

4.1.2.5. efficient is NOT a primary goal

4.1.2.6. clean, redundancy free design

4.2. 2) Physical-level design

4.2.1. specific DBMS

4.2.2. characteristics of DBMS

4.2.3. performance of the system

4.2.3.1. space

4.2.3.2. processing time

4.2.3.3. response time

4.2.4. goal can conflict with goals of info-level design

4.2.4.1. can introduce redundancy for speed

4.2.4.2. may not be able to 3NF with required efficiency

4.2.5. controlled changes

4.2.5.1. deviations documented

4.2.5.2. list of all restrictions

4.3. 3) Final database structure

5. schemas

5.1. types

5.1.1. physical view

5.1.1.1. internal schema

5.1.1.2. hierarchical manner in which data is stored on disk

5.1.2. logical view

5.1.2.1. conceptual schema

5.1.2.2. overall description of entire database

5.1.3. external view

5.1.3.1. user view

5.1.3.2. describes the way an individual user views appoication

5.2. Basic database design methodology

5.2.1. 1) represent user view as collection of relations

5.2.1.1. 1) determine the entities involved / create separate relation for each type of entity

5.2.1.2. 2) determine the primary key for each relation

5.2.1.3. 3) determine the properties for each relation

5.2.1.4. 4) determine the relationship among the entities

5.2.1.4.1. 1:1

5.2.1.4.2. 1:M

5.2.1.4.3. N:M

5.2.2. normalize the relations

5.2.2.1. 3NF - typical result

5.2.2.2. 4NF - typical target

5.2.2.3. analysis early eliminates issues so 3NF is ok

5.2.3. represent all keys

5.2.3.1. primary

5.2.3.2. alternative

5.2.3.3. secondary

5.2.3.4. foreign

5.2.3.4.1. nulls

5.2.3.4.2. updating

5.2.3.4.3. deleting

5.2.3.5. surrogate

5.2.4. merge the result into design

5.2.4.1. add the relations

5.2.4.2. combine relations that have same primary key

5.2.4.3. new relation

5.2.4.3.1. same primary key

5.2.4.3.2. attributes from both relations

5.2.4.3.3. remove dublicates

5.2.4.3.4. 3NF

5.2.4.3.5. merge special restrictions

6. Oracle statements

6.1. Oracle does not support CASCADE UPDATE constraint

6.2. Money or currency in Oracle is Numeric

6.3. Oracle sequences must be used for surrogate keys

6.3.1. NextVal

6.3.2. CurrVal

6.3.3. doesn't guarantee valid surrogate key values

6.3.4. CREATE SEQUENCE CustID INCREMENT BY 1 START WITH 1000;

6.4. The DESCRIBE or DESC command is used to view table status

6.5. data types

6.5.1. BLOB

6.5.2. CHAR(n)

6.5.3. DATE

6.5.4. INT

6.5.5. NUMBER (n,d)

6.5.6. VARCHAR(n)

6.5.7. VARCHAR2(n)

7. General Info

7.1. Why use SQL instead of graphical tool for DBMS management task?

7.1.1. creating tables and relationships is faster with SQL

7.1.2. repeatable for apps that require same tables, reports, etc.

7.1.3. Some apps require temp tables to be created during the app

7.1.4. SQL DDL is standardized and DBMS independent (transferable)

7.2. procedural language extensions

7.2.1. Transact-SQL (T-SQL) - SQL Server

7.2.2. Procedural Language/SQL (PL/SQL) - Oracle