Database
Database
• Relational DBMS
• Represent data as two-dimensional tables called relations or files
• Each table contains data on entity
• Table: grid of columns and rows
• Rows (tuples): Records for different entities
• Fields (columns): Represents attribute for entity
• Key field: Field used to uniquely identify each record
• Primary key: Field in table used for key fields
• Foreign key: Primary key used in second table as look-up field to
identify records from original table
A relational database organizes data in the form of two-dimensional tables. Illustrated here are tables for
the entities SUPPLIER and PART showing how they represent each entity and its attributes.
Supplier_Number is a primary key for the SUPPLIER table and a foreign key for the PART table.
Figure 6-4A
Database Systems Slide 8
Relational Database Tables (cont.)
Figure 6-4B
Database Systems Slide 9
Database Operations
• The user of a database system can perform the following
operations using SQL (Structured Query Language):
- Defining structure and types of data (Data Definition
Language: DDL)
- Data manipulation (Insert, Delete, Update, Query etc.)
Data Manipulation Language (DML)
An unnormalized relation contains repeating groups. For example, there can be many parts and suppliers
for each order. There is only a one-to-one correspondence between Order_Number and Order_Date.
Figure 6-9
Database Systems Slide 18
Normalized Tables Created from Order
After normalization, the original relation ORDER has been broken down into four smaller relations. The
relation ORDER is left with only two attributes and the relation LINE_ITEM has a combined, or
concatenated, key consisting of Order_Number and Part_Number.
Figure 6-10
Database Systems Slide 19
SQL JOIN
• A JOIN clause is used to combine rows from two or more tables
based on related column between them
Inner Join
Left Join
Right Join
Full Outer Join
Self Join
Natural Join
Theta Join