SQL DATABASE Flashcards
Schema
Describes table
How is each row represented in a Relational Database
As a Tuple
Represents a record of related data values
Each Row
Each row has 2 properties
- Represents a record of related data values
- Facts that typically correspond to a real-world entity or relationship
- Facts that typically correspond to a real-world entity or relationship
Each Row
How is each column represented in a relational database
Attribute
Each column has 2 properties
- Holds a corresponding value for each row
- Slot for a specific interpretation for a row
- Slot for a specific interpretation for a row
Each Column
What is a Schema
Describes a table (table name, attribute name, types)
What is an instance
Denotes the current contents of the table
Set of atomic values * {0,1,2,…} * {Jo Smith, Dana Jones, Ashley Wong, Y. K. Lee,…}
Domain D
Atomic has 2 descriptions
- Each value indivisible Domain specified by Data type rather than by enumeration
- Integer, String, Date, Real, etc. * Can be specified by format: (ddd)ddd-dddd
A relation schema is denoted by
by R(A1 , A2 , …, An )
A relation name R and a list of attributes: A1 , A2 , …, An
Relation Schema
Name of a role in the relation schema R
Attribute
Associated with a domain dom(ai)
Attribute
(T OR F) Attribute names do not repeat within a relation schema(table) but domains can repeat.
True
- The relation (or relation state)
Instance
Number of attribute n in its relation schema
Degree of a relation (no. of columns)
Enumerate the behaviors of values in tuples (6)
Each value in a tuple is atomic
* Flat (as opposed to nested) relational model
* Composite and multivalued attributes not allowed
* Historically relation is said to be in First normal form (1NF) Composite attributes
* Split into simple component attributes
* e.g., Waterloo, Ontario treated as atomic or split into two attributes to store Waterloo
separately from Ontario Multivalued attributes
* Must be represented by separate relations
Enumerate the 4 Behaviors of Null Values
Assume each domain is augmented with a special NULL value
* Represent the values of attributes that may be unknown or may not apply to a tuple
Interpretations for NULL values
* Nothing is known about the value
* Value exists but is (currently) not available
5 basic concepts of Entity-Relationship model
Entity
Attributes
Entity Type
Entity Set
Key Attribute
A thing in the real world with an independent existence.
entity
May be an object with physical existence or with a conceptual existence
Entity
- properties that describe the entities
Attributes
A collection of entities that have the same attributes
Entity Type
A collection of entities of a particular entity type at a point in time.
Entity Set
An attribute that is capable of identifying each entity uniquely.
Key Attribute
6 types of Attributes
Composite Attributes
Simple Attributes
Single-valued Attributes
Multivalued Attributes
Stored Attributes
Complex Attributes
Derived Attributes