Download presentation
Presentation is loading. Please wait.
1
Relational Database Design
Structured Query Language (SQL)
2
A Database Structure
3
Database Building Blocks
4
Structure of a Relational Database
5
Training Database Schema
6
Normalization Theory (1 of 2)
Normalization is an integral technique of a bottom-up approach. Normalization theory is used as a design verification technique in a top-down approach.
7
Normalization Theory (2 of 2)
“A record is in second and third normal form if every field is either part of the key or provides a (single-valued) fact about exactly the whole key and nothing else” “A table is in third normal form if every non-key field depends upon The primary key. The whole key. And nothing but the key”
8
Scope of Normalization (1 of 4)
This theory is applicable to any DBMS. Not just relational.
9
Scope of Normalization (2 of 4)
It is applicable to the design of simple files as well.
10
Scope of Normalization (3 of 4)
Normalization theory is a process of decomposing tables or records from an un-normalized form to a normalized form. Each decomposition reduces the possibility of errors or anomalies occurring during database update processing.
11
Scope of Normalization (4 of 4)
Applying the normalization process. Tables are transformed to a higher normal form. Note that 5th normal form (5NF) is a theoretical ideal.
12
Benefit and Cost of Normalization (1 of 4)
The ultimate benefit derived from applying normalization theory is a stable design. Reducing the chance of update errors.
13
Benefit and Cost of Normalization (2 of 4)
In order to implement a database through the normalization process. One must have a real understanding of the semantics (meaning) of each data item. This forces the database designer to effectively communicate with the users of the database.
14
Benefit and Cost of Normalization (3 of 4)
Users understand clearly the meaning of data in relations so they correctly formulate queries.
15
Benefit and Cost of Normalization (4 of 4)
There is extra an effort of joining and tables.
16
Functional Dependence (1 of 2)
Given a relation R. Attribute Y of R is functionally dependent on attribute X of R if each X-value of R has associated with it precisely one Y-value of R (at any one time). Attributes X and Y may be composite.
17
Functional Dependence (2 of 2)
Functional dependence means: "You tell me X and I'll tell you Y" Notation: R.X R.Y Examples: STUDNO SNAME STUDNO SAGE COURSENO CNAME POLICYNO NAME-OF-INSURED CLAIMNO POLICYNO
18
Functional Dependence
Functional dependence is not limited to a single data item. It can be extended to a collection of fields. Notation: A,BC
19
Functional dependence is a semantic notion.
An understanding of the meaning of data items in the application domain is required. Applying functional dependence enables the designer to identify keys.
20
Candidate key If a field uniquely identifies every other field in a given table. It is a candidate key. Alternatively: If every field in a table is functionally dependent on field k. Then k is a candidate key.
21
Composite key Sometimes a candidate key is a composite key
A single data item is not sufficient to determine the other data items of the record.
22
First Normal Form For a table to be in First Normal Form (1NF).
All data item values must be atomic. This means that there are no repeating groups. In a table. Every row-column intersection holds a single value. Not a set of values.
23
Unnormalized table.
24
First Normal form
25
Second Normal form
26
Third Normal form
27
Transitive Dependency
28
Same category of information
Tables Header row Row Same category of information Column Related information
29
Information retrieved
Databases Database Table 1 Table 2 Table 3 Table 4 Information searched Database objects Information retrieved
30
Databases (Cont.)
31
Databases (Cont.) Default databases Customized databases
32
Servers Higher performance No user Manage resource Provide services
Network Client 1 Client 2 Client 3 Server
33
Clients Client 1 Client 2 Client 3 Server Connected to the same
network as the server Displays result Requests the service of the server
34
characters are allowed
Data Types Alphanumeric values Only numeric values are allowed Data types characters are allowed Numeric values
35
Datatypes
36
SSMS Shortcuts
38
The Inner Join Tables to be joined
Keyword entered between two table names Condition containing the comparison operator Tables to be joined Records that have matching values
39
The Outer Join Column used to join tables
Keyword entered between two table names ON clause containing the condition Column used to join tables Matching rows from both tables Rows from one table Output after joining two tables
40
SQL Logical Query Processing Steps
Clause Order Logical Processing Steps SELECT FROM JOIN____ON____ WHERE GROUP BY HAVING ORDER BY FROM ON OUTER WHERE GROUP BY CUBE | ROLLUP HAVING SELECT DISTINCT ORDER BY TOP
41
The CREATE TABLE Statement
Table name Restricts storage of null value Size enclosed within parentheses Datatype and size specified Column names and definitions
42
Table Design Columns Rows Column header
43
Data Integrity All values are valid and can be used further qty<225
Column contains valid data Linked columns have matching values Each record is unique
44
Constraints Qty>0 Column-level constraint Defines rules to
test column value Domain integrity implemented
45
Primary Keys Primary key Uniquely identifies each column
Cannot store null or duplicate values
46
PRIMARY KEY Constraints
Constraint name Prevents record duplication Creates primary key on this column Table-level constraint Column name chosen as primary key
47
UNIQUE Constraints Can accept null values Column-level
Implements uniqueness in values stored Can accept null values
48
Foreign Keys Foreign key Can store Primary key of duplicate values
Stores matching values Links records Primary key of referenced table Referenced table
49
FOREIGN KEY Constraints
Defined when creating a table Referenced table name Column-level constraint Referenced column Cannot be modified once created without being deleted Foreign key name Creates the foreign key Table-level constraint
50
column-level constraint
DEFAULT Constraints Specified when creating a table Specified only as a column-level constraint Specifies a default value for a column Value must correspond to the datatype of the column
51
value based on condition
CHECK Constraints Validates column value based on condition Executed in the order specified Multiple expressions linked Column-level CHECK constraint Table-level Logical expression
52
The ALTER TABLE Statement
Modifies table structure Adds a column Modifies column definitions Adds a constraint Drops a column Drops a constraint
53
Sparse Columns Table name Sparse attribute for the ‘deptno’ column
Column definition Code to be inserted here .
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.