customer
Documentation | Sakila |
Name | customer |
Module | Customer Data |
The customer table contains a list of all customers.
The customer table is referred to in the payment and rental tables and refers to the address and store tables using foreign keys.
Columns
Key | Name | Data type | Null | Attributes | References | Description | ||
---|---|---|---|---|---|---|---|---|
1 | customer_id | unsigned smallint(5, 0) | Identity / Auto increment column | A surrogate primary key used to uniquely identify each customer in the table. | ||||
A surrogate primary key used to uniquely identify each customer in the table. Identity / Auto increment column |
||||||||
2 | store_id | unsigned tinyint(3, 0) | store | A foreign key identifying the customer's “home store.” Customers are not limited to renting only from this store, but this is the store they generally shop at. | ||||
A foreign key identifying the customer's “home store.” Customers are not limited to renting only from this store, but this is the store they generally shop at. References: store |
||||||||
3 | first_name | varchar(45) | The customer's first name. | |||||
The customer's first name. |
||||||||
4 | last_name | varchar(45) | The customer's last name. | |||||
The customer's last name. |
||||||||
5 | varchar(50) | The customer's email address. | ||||||
The customer's email address. |
||||||||
6 | address_id | unsigned smallint(5, 0) | address | A foreign key identifying the customer's address in the address table. | ||||
A foreign key identifying the customer's address in the address table. References: address |
||||||||
7 | active | tinyint(3, 0) | Default: 1 | Indicates whether the customer is an active customer. Setting this to FALSE serves as an alternative to deleting a customer outright. Most queries should have a WHERE active = TRUE clause. | ||||
Indicates whether the customer is an active customer. Setting this to FALSE serves as an alternative to deleting a customer outright. Most queries should have a WHERE active = TRUE clause. Default: 1 |
||||||||
8 | create_date | datetime | The date the customer was added to the system. This date is automatically set using a trigger during an INSERT. | |||||
The date the customer was added to the system. This date is automatically set using a trigger during an INSERT. |
||||||||
9 | last_update | timestamp | Default: CURRENT_TIMESTAMP | The time that the row was created or most recently updated. | ||||
The time that the row was created or most recently updated. Default: CURRENT_TIMESTAMP |
Relations
Foreign table | Primary table | Join | Title / Name / Description | |
---|---|---|---|---|
customer | address | customer.address_id = address.address_id | fk_customer_address Foreign key constraint referencing address.address_id |
|
customer.address_id = address.address_id Name: fk_customer_addressForeign key constraint referencing address.address_id |
||||
customer | store | customer.store_id = store.store_id | fk_customer_store Foreign key constraint referencing store.store_id |
|
customer.store_id = store.store_id Name: fk_customer_storeForeign key constraint referencing store.store_id |
||||
payment | customer | payment.customer_id = customer.customer_id | fk_payment_customer Foreign key constraint referencing customer.customer_id |
|
payment.customer_id = customer.customer_id Name: fk_payment_customerForeign key constraint referencing customer.customer_id |
||||
rental | customer | rental.customer_id = customer.customer_id | fk_rental_customer Foreign key constraint referencing customer.customer_id |
|
rental.customer_id = customer.customer_id Name: fk_rental_customerForeign key constraint referencing customer.customer_id |
Unique keys
Key name | Columns | Description | |
---|---|---|---|
PRIMARY | customer_id | Primary key. | |
Primary key. |
Triggers
Key name | When | Description | |
---|---|---|---|
customer_create_date | Before Insert | The customer_create_date trigger sets the create_date column of the customer table to the current time and date as rows are inserted. | |
The customer_create_date trigger sets the create_date column of the customer table to the current time and date as rows are inserted. |
Exported: 2018-10-12 17:43, Last imported: 2018-08-06 10:44