Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
30 views

Lecture 06 - Creating Tables Using SQL

This document discusses creating relations using SQL. It begins with an overview of SQL and its environment including data definition language, data manipulation language, and data control language. It then describes SQL data types and provides examples of creating tables using data definition language statements. The slides that follow demonstrate creating tables for an enterprise data model, identifying foreign keys, establishing relationships between tables, specifying primary keys and foreign keys, and applying domain constraints.

Uploaded by

Hassan Elbayya
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Lecture 06 - Creating Tables Using SQL

This document discusses creating relations using SQL. It begins with an overview of SQL and its environment including data definition language, data manipulation language, and data control language. It then describes SQL data types and provides examples of creating tables using data definition language statements. The slides that follow demonstrate creating tables for an enterprise data model, identifying foreign keys, establishing relationships between tables, specifying primary keys and foreign keys, and applying domain constraints.

Uploaded by

Hassan Elbayya
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

BIS315E

Advanced Databases

Lecture 4
Creating Relations using SQL
Systems Development Database
Life Cycle Development Process
Project Identification Enterprise modeling
and Selection
Project Initiation
and Planning Conceptual data modeling
Analysis

Logical Design Logical database design

Physical database design


Physical Design
and definition
Implementation Database implementation

Maintenance Database maintenance


2
SQL Overview
 Structured Query Language
 The standard for relational database
management systems (RDBMS)
 SQL-92 and SQL-99 Standards – Purpose:
 Specify syntax/semantics for data definition and
manipulation
 Define data structures
 Enable portability
 Specify minimal (level 1) and complete (level 2)
standards
 Allow for later growth/enhancement to standard

3
SQL Environment
 Catalog
 A set of schemas that constitute the description of a
database
 Schema
 The structure that contains descriptions of objects
created by a user (base tables, views, constraints)
 Data Definition Language (DDL)
 Commands that define a database, including creating,
altering, and dropping tables and establishing
constraints
 Data Manipulation Language (DML)
 Commands that maintain and query a database
 Data Control Language (DCL)
 Commands that control a database, including
administering privileges and committing data 4
SQL Data types
(from Oracle 9i)
 String types
 CHAR(n) – fixed-length character data, n characters long
Maximum length = 2000 bytes
 VARCHAR2(n) – variable length character data, maximum
4000 bytes
 LONG – variable-length character data, up to 4GB. Maximum
1 per table
 Numeric types
 NUMBER(p,q) – general purpose numeric data type
 INTEGER(p) – signed integer, p digits wide
 FLOAT(p) – floating point in scientific notation with p binary
digits precision
 Date/time type
 DATE – fixed-length date/time in dd-mm-yy form
5
6
SQL Database Definition
 Data Definition Language (DDL)
 Major CREATE statements:
 CREATE SCHEMA – defines a portion of the
database owned by a particular user
 CREATE TABLE – defines a table and its columns
 CREATE VIEW – defines a logical table from one
or more views
 Other CREATE statements: CHARACTER SET,
COLLATION, TRANSLATION, ASSERTION,
DOMAIN

7
The following slides create tables for
this enterprise data model

8
Relational Data Model

9
Identifying foreign keys and establishing relationships

Primary key of
parent table

Foreign key of
dependent table

10
Non-nullable specifications

Primary key

Some primary keys are composite –


composed of multiple attributes

11
Controlling the values in attributes

Domain constraint
PRIMARY KEY (PRODUCT_ID));

12

You might also like