The document outlines the creation of a database schema for a car rental service, including tables for Clients, Employees, Cars, Places, and Rent transactions. It specifies the structure of each table, including fields and data types, and includes sample data insertion for each table. The schema establishes relationships between tables through primary and foreign keys to maintain data integrity.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
13 views4 pages
SQL v2 Tworzenie
The document outlines the creation of a database schema for a car rental service, including tables for Clients, Employees, Cars, Places, and Rent transactions. It specifies the structure of each table, including fields and data types, and includes sample data insertion for each table. The schema establishes relationships between tables through primary and foreign keys to maintain data integrity.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4
CREATE TABLE Client (
ClientID INT NOT NULL IDENTITY CONSTRAINT pk_client PRIMARY KEY,
FirstName VARCHAR(20) NOT NULL, LastName VARCHAR(20) NOT NULL, CreditCardNumber CHAR(20), Company VARCHAR(40), Street VARCHAR(24) NOT NULL, Number CHAR(8) NOT NULL, City VARCHAR(24) NOT NULL, PostCode CHAR(6) NOT NULL, TaxID CHAR(12), PhoneNumber CHAR(12) );
CREATE TABLE Employee (
EmployeeID INT NOT NULL IDENTITY CONSTRAINT pk_employee PRIMARY KEY, FirstName VARCHAR(20) NOT NULL, LastName VARCHAR(20) NOT NULL, EmpDate DATETIME NOT NULL, Department VARCHAR(20), Position VARCHAR(20), Salary DECIMAL(8,2), ExtSalary DECIMAL(8,2), PlaceID INT NOT NULL, PhoneNumber CHAR(16), /////////////////////// CONSTRAINT fk_place FOREIGN KEY (PlaceID) REFERENCES Place(PlaceID) );
CREATE TABLE Car (
CarID INT NOT NULL IDENTITY CONSTRAINT pk_car PRIMARY KEY, Brand VARCHAR(20) NOT NULL, Model VARCHAR(16) NOT NULL, ProdYear DATETIME NOT NULL, Color VARCHAR(16) NOT NULL, EngineVol SMALLINT NOT NULL, Mileage INT NOT NULL );
CREATE TABLE Place (
PlaceID INT NOT NULL IDENTITY CONSTRAINT pk_place PRIMARY KEY, Street VARCHAR(24) NOT NULL, Number CHAR(8) NOT NULL, City VARCHAR(24) NOT NULL, PostCode CHAR(6) NOT NULL, PhoneNumber CHAR(12), Note VARCHAR(40) );
CREATE TABLE Rent (
RentID INT NOT NULL IDENTITY CONSTRAINT pk_rent PRIMARY KEY, ClientID INT NOT NULL, CarID INT NOT NULL, RentEmployeeId INT NOT NULL, ReturnEmployeeId INT NOT NULL, RentPlaceId INT NOT NULL, ReturnPlaceId INT NOT NULL, RentDate DATETIME NOT NULL, ReturnDate DATETIME NOT NULL, Deposit DECIMAL(8,2), UnitPrice DECIMAL(8,2),