CSC232 Introduction to Database System Lect 2
CSC232 Introduction to Database System Lect 2
Columns
Definition
A column, also known as an attribute or field, defines a particular type of data stored in a
table.
Characteristics
- Data Type: Each column has a defined data type (e.g., INTEGER, VARCHAR, DATE) that
dictates the kind of data it can store.
- Constraints: Columns can have constraints applied to them, such as NOT NULL (which
means the column cannot store NULL values), UNIQUE (which ensures all values in the
column are unique), and DEFAULT (which provides a default value if none is specified).
- Column Name: Each column within a table has a unique name that identifies it.
Example
In the `Customers` table, the columns and their characteristics are as follows:
CustomerID, FirstName, LastName, Email, DateOfBirth
Introduction to Entity Relationship (ER)
Model
Definition
The Entity Relationship (ER) model is a conceptual framework used to describe the
data and its relationships within a database. Introduced by Peter Chen in 1976, the ER
model provides a graphical representation of the logical structure of a database,
focusing on entities, their attributes, and the relationships between them.
Key Components of the ER Model
1. Entities
- Definition: An entity is a distinct object or thing in the real world that can be
distinctly identified. Entities represent objects or concepts that have a significant role
in the domain being modeled.
- Example: In a university database, entities might include `Student`, `Course`, and
`Professor`.
Key Components of the ER
Model Contd.
2. Attributes
- Definition: Attributes are the properties or characteristics of an entity. Each attribute
represents a specific piece of information about the entity.
- Types
- Simple Attributes: Indivisible attributes, such as `FirstName` and `LastName`.
- Composite Attributes: Attributes that can be subdivided into smaller parts, such as
`FullName` which can be divided into `FirstName` and `LastName`.
- Derived Attributes: Attributes that can be derived from other attributes, such as `Age`
derived from `DateOfBirth`.
- Multi-valued Attributes: Attributes that can have multiple values, such as `PhoneNumbers`
for a person who has more than one phone number.
- Example: For the `Student` entity, attributes might include `StudentID`, `Name`, `Email`, and
`DateOfBirth`.
Key Components of the ER Model Contd.
3. Relationships
- Definition: Relationships describe how entities are related to one another. They
represent the associations between entities.
- Types:
- One-to-One (1:1): Each instance of one entity is associated with a single
instance of another entity.
- One-to-Many (1:N): An instance of one entity is associated with multiple
instances of another entity.
- Many-to-Many (M:N): Instances of one entity are associated with multiple
instances of another entity, and vice versa.
- Example: A `Student` enrolling in a `Course` represents a relationship. One
student can enroll in many courses, and one course can have many students, making
it a many-to-many relationship.
Key Components of the ER Model Contd.