Upload
bruce-warren
View
214
Download
1
Embed Size (px)
Citation preview
Texas State Technical College
DISCOVER!
Database TablesDatabase Tables
The building blocks of the relational database.
Texas State Technical College
DISCOVER!
Database Tables
The The tabletable is the basic structure of all is the basic structure of all relational databases. relational databases. One table represents One table represents one one type of objecttype of object in the real world in the real world domain.domain.
The table’s main purposes are:The table’s main purposes are:
• Define the object and all its attributesDefine the object and all its attributes
• Store all the instances of that object typeStore all the instances of that object type
Table PurposeTable Purpose
Texas State Technical College
DISCOVER!
Database Tables
Generic Object Type Generic Object Type (defined (defined byby the table) the table)• EngineEngine
Instances of the Engine Generic Type Instances of the Engine Generic Type (stored (stored inin the table) the table)• Ford 4 cylinderFord 4 cylinder• Ford V-6Ford V-6• Ford V-8Ford V-8• Dodge V-12Dodge V-12
Table Purpose IllustrationTable Purpose Illustration
Texas State Technical College
DISCOVER!
Database TablesTable CompositionTable Composition
Each table has two primary components.Each table has two primary components.
• Table DefinitionTable Definition• AttributeAttribute (field)(field)• Attribute type Attribute type (datatype)(datatype)• RelationshipRelationship (key)(key)
• Table DataTable Data• Instances Instances (records)(records)
Texas State Technical College
DISCOVER!
Database TablesTable DefinitionTable Definition
Defines the characteristics of one generic Defines the characteristics of one generic type of object.type of object.
The definition for a table is a list of pairs The definition for a table is a list of pairs {attribute name, attribute type}{attribute name, attribute type}
Any attribute/characteristic listed must be Any attribute/characteristic listed must be common to all objects of the object type.common to all objects of the object type.
Texas State Technical College
DISCOVER!
Database TablesTable Definition ExampleTable Definition Example
Name Volume Cylinders Max Torque Max RPM
Text Decimal Integer Integer Integer
[ ENGINE ]
Think of all the engines that exist or that you wish to model. The engine table describes a generic engine. It must define all the attributes that are common for all automotive engines. Below are only a few of the common characteristics/attributes in both a graphical and text based representation.
[ {Name, Text}, {Volume, Decimal}, {Cylinders, Integer}, {Max Torque, Integer}, {Max RPM, Integer} ]
Texas State Technical College
DISCOVER!
Database TablesTable DataTable Data
Stores all specific instances of the object Stores all specific instances of the object type.type.
Each instance or record represents one Each instance or record represents one existing or actual object of the object existing or actual object of the object type specified by the table.type specified by the table.
Each instance or record is a list of pairs Each instance or record is a list of pairs {attribute name, attribute value}{attribute name, attribute value}
Texas State Technical College
DISCOVER!
Database TablesTable Data ExampleTable Data Example
Name Volume Cylinders Max Torque Max RPM
Ford 4 Cylinder 2.6 4 800 5200
[ ENGINE ]
Each instance of the object type is referred to as a record. Each record is visualized as below in two different ways, as graphical and as text. There are two records, one describing a Ford 4 cylinder engine and the other a Ford V-6 engine.
Name Volume Cylinders Max Torque Max RPM
Ford V-6 3.6 6 1400 7200
[ {Name, Ford 4 Cylinder}, {Volume, 2.6}, {Cylinders, 4}, {Max Torque, 800}, {Max RPM, 5200} ]
[ {Name, Ford V-6}, {Volume, 3.6}, {Cylinders, 6}, {Max Torque, 1400}, {Max RPM, 7200} ]
RECORD #1
RECORD #2
Texas State Technical College
DISCOVER!
Database TablesTable CompositionTable Composition
Name Volume Cylinders Max Torque Max RPM
Text Decimal Integer Integer Integer
Ford V-6 3.6 litre 6 1400 7200
Ford 4 Cylinder 2.6 litre 4 800 5200
[ ENGINE ]
When we combine the two components, we get something most of us are a little more used to seeing. It is a lot like an Excel spreadsheet, except in a table all the cells or fields in a row are related because they describe one actual object.
DEFINITION
DATA
Texas State Technical College
DISCOVER!
Database TablesIn Summary…In Summary…
• The two basic components of tables are the table The two basic components of tables are the table definitiondefinition and the table and the table datadata..
• Relational databases define Relational databases define object typesobject types and store and store occurrences of that object type through the use of occurrences of that object type through the use of tables.tables.
• Tables are composed of Tables are composed of fields fields and and recordsrecords..
• Fields are used to define the Fields are used to define the attributes attributes of an object of an object type.type.
• Records are used to store individual occurrences or Records are used to store individual occurrences or instancesinstances of an object type. of an object type.