B103 Basics - Architecture
B103 Basics - Architecture
32
67
12
90
54
75
18
25
80
41
Notes:
Teradata
Parsing
Engine(s)
AMP 1
2
18
5
4
AMP 2
12
41
AMP 3
80
9
0
75
AMP 4
3
2
67
2
5
32
67
12
90
54
75
18
25
80
41
Teradata
Notes:
The Parsing Engine dispatches a
request to retrieve one or more
rows.
Parsing
Engine(s)
AMP 1
2
18
5
4
AMP 2
12
41
AMP 3
80
9
0
75
AMP 4
3
2
67
2
5
DEPARTMENT Table
JOB Table
Notes:
Some rows from each table may
be found on each AMP.
Parsing Engine
AMP #1
AMP #2
EMPLOYEE Rows
EMPLOYEE Rows
DEPARTMENT Rows DEPARTMENT Rows
JOB Rows
JOB Rows
AMP #3
EMPLOYEE Rows
DEPARTMENT Rows
JOB Rows
EMPLOYEE Rows
DEPARTMENT Rows
JOB Rows
Parsing
Engine
Parsing
Engine
Parsing
Engine
SESSIO
Teradata is a linearly
NS
expandable RDBMS.
AMP
requirements grow.
AMP
AMP
I
OCESS
R
P
L
E
L
PARAL
NG
Disk
Disk
Disk
Notes:
DATA
USERS
Same
Double
Same
Same
AMPs
Same
Double
Double
Double
DATA
Same
Same
Double
Same
Performance
Same
Same
Same
Double
Teradata Objects
There are eight types of objects which may be found in a Teradata database/user.
Tables rows and columns of data
Views predefined subsets of existing tables
Macros predefined, stored SQL statements
Triggers SQL statements associated with a table
Stored Procedures program stored within Teradata
Join and Hash Indexes separate index structures stored as objects within a database
Permanent Journals table used to store before and/or after images for recovery
DATABASE or USER
These objects are created,
maintained and deleted using
Structured Query Language (SQL).
Object definitions are stored in the
Data Dictionary / Directory (DD/D).
DD/D
DEFINITIONS OF
ALL DATABASE
OBJECTS
TABLE 1
TABLE 2
TABLE 3
VIEW 1
VIEW 2
VIEW 3
MACRO 1
MACRO 2
MACRO 3
TRIGGER 1
TRIGGER 2
TRIGGER 3
Stored Procedure 1
Stored Procedure 2
Stored Procedure 2
Join/Hash Index 1
Join/Hash Index 2
Join/Hash Index 3
Permanent Journal
DBC.Users
DBC.AllRights
DBC.AllSpace
DROP
ALTER
INSERT
UPDATE
DELETE
REVOKE
SHOW
EXPLAIN
CREATE MACRO
Views
Views are pre-defined subsets of existing tables consisting of specified
columns and/or rows from the table(s).
A single table view:
is a window into an underlying table
allows users to read and update a subset of the underlying table
has no data of its own
EMPLOYEE (Table)
MANAGER
EMPLOYEE EMP
NUMBER
NUMBER
DEPT
NUMBER
JOB
CODE
PK
FK
FK
FK
1006
1008
1005
1004
1007
1003
1019
1019
0801
1003
1005
0801
301
301
403
401
403
401
312101
312102
431100
412101
432101
411100
LAST
NAME
Stein
Kanieski
Ryan
Johnson
Villegas
Trader
FIRST
NAME
HIRE
DATE
BIRTH
DATE
SALARY
AMOUNT
John
Carol
Loretta
Darlene
Arnando
James
861015
870201
861015
861015
870102
860731
631015
680517
650910
560423
470131
570619
3945000
3925000
4120000
4630000
5970000
4785000
Emp_403 (View)
EMP NO
1005
801
DEPT NO
403
403
LAST NAME
Villegas
Ryan
FIRST NAME
Arnando
Loretta
HIRE DATE
870102
861015
Multi-Table Views
A multi-table view allows users to access data from multiple tables as if it were in a single
table. Multi-table views are also called join views. Join views are used for reading only,
not updating.
EMPLOYEE (Table)
MANAGER
EMPLOYEE EMP
NUMBER
NUMBER
DEPT
NUMBER
JOB
CODE
PK
FK
FK
FK
1006
1008
1005
1004
1007
1003
1019
1019
0801
1003
1005
0801
301
301
403
401
403
401
312101
312102
431100
412101
432101
411100
LAST
NAME
Stein
Kanieski
Ryan
Johnson
Villegas
Trader
FIRST
NAME
HIRE
DATE
BIRTH
DATE
SALARY
AMOUNT
John
Carol
Loretta
Darlene
Arnando
James
861015
870201
861015
861015
870102
860731
631015
680517
650910
560423
470131
570619
3945000
3925000
4120000
4630000
5970000
4785000
DEPARTMENT (Table)
DEPT
NUMBER
DEPARTMENT
NAME
MANAGER
BUDGET EMP
AMOUNT NUMBER
PK
501
301
302
403
402
401
201
FK
marketing sales
research and development
product planning
education
software support
customer support
technical operations
80050000
46560000
22600000
93200000
30800000
98230000
29380000
1017
1019
1016
1005
1011
1003
1025
"Joined Together"
EmpDept (View)
LAST
DEPARTMENT
NAME
NAME
Stein
Kanieski
Ryan
Johnson
Villegas
Trader
DEPT
NUMBER
JOB
CODE
PK
FK
FK
FK
1006
1008
1005
1004
1007
1003
1019
1019
0801
1003
1005
0801
301
301
403
401
403
401
312101
312102
431100
412101
432101
411100
LAST
NAME
Stein
Kanieski
Ryan
Johnson
Villegas
Trader
FIRST
NAME
HIRE
DATE
BIRTH
DATE
SALARY
AMOUNT
John
Carol
Loretta
Darlene
Arnando
James
861015
870201
861015
861015
870102
860731
631015
680517
650910
560423
470131
570619
3945000
3925000
4120000
4630000
5970000
4785000
Result
SELECT Last_Name
,First_Name
FROM
Employee
WHERE Hire_Date = '1986-10-15'
;
LAST
NAME
Stein
Ryan
Johnson
FIRST
NAME
John
Loretta
Darlene
DEPT
NUMBER
JOB
CODE
PK
FK
FK
FK
1006
1008
1005
1004
1007
1003
1019
1019
0801
1003
1005
0801
301
301
403
401
403
401
312101
312102
431100
412101
432101
411100
LAST
NAME
Stein
Kanieski
Ryan
Johnson
Villegas
Trader
FIRST
NAME
HIRE
DATE
BIRTH
DATE
SALARY
AMOUNT
John
Carol
Loretta
Darlene
Arnando
James
861015
870201
861015
861015
870102
860731
631015
680517
650910
560423
470131
570619
3945000
3925000
4120000
4630000
5970000
4785000
DEPARTMENT
DEPT
NUMBER
DEPARTMENT
NAME
MANAGER
BUDGET EMP
AMOUNT NUMBER
PK
501
301
302
403
402
401
201
FK
marketing sales
research and development
product planning
education
software support
customer support
technical operations
80050000
46560000
22600000
93200000
30800000
98230000
29380000
1017
1019
1016
1005
1011
1003
1025
Result
LAST
NAME
Stein
Kanieski
FIRST
NAME
John
Carol
To create a macro:
CREATE MACRO Customer_List AS (SELECT customer_name FROM Customer;);
To execute a macro:
EXEC Customer_List;
To replace a macro:
REPLACE MACRO Customer_List AS
(SELECT customer_name, customer_number FROM Customer;);
DATABASE
Customer_Service ;
HELP
USER
Dave_Jones ;
TABLE
Employee ;
HELP
VIEW
Emp;
HELP
MACRO
Payroll_3;
HELP
COLUMN
Employee.*;
Employee.last_name;
Emp.* ;
Emp.last;
HELP
INDEX
Employee;
HELP
STATISTICS
Employee;
HELP
CONSTRAINT Employee.over_21;
Kind
T
T
V
V
I
T
T
T
T
T
T
T
T
M
M
Comment
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
tablename;
viewname;
macroname;
triggername;
procedurename;
Returns statement
CREATE TABLE statement
CREATE VIEW ...
CREATE MACRO ...
CREATE TRIGGER
CREATE PROCEDURE
Win XP
Teradata
DATABASE
UNIX
Client
Mainframe
Client
Review Questions
1. What language is used to access a Teradata table?