CREATE TABLE GPS_Positions (
    ID INT IDENTITY(1,1) PRIMARY KEY,
    DeviceID NVARCHAR(50) NOT NULL,
    Latitude DECIMAL(10,7) NOT NULL,
    Longitude DECIMAL(10,7) NOT NULL,
    Speed DECIMAL(10,2) NOT NULL DEFAULT 0,
    Course INT NOT NULL DEFAULT 0,
    Moving BIT NOT NULL DEFAULT 0,
    VoltageV DECIMAL(5,2) NOT NULL DEFAULT 0,
    UpdateTime DATETIME NOT NULL,
    CreatedTime DATETIME NOT NULL DEFAULT GETDATE(),
    CONSTRAINT UC_DeviceID UNIQUE (DeviceID)
);

CREATE INDEX IX_GPS_Positions_DeviceID ON GPS_Positions(DeviceID);
CREATE INDEX IX_GPS_Positions_UpdateTime ON GPS_Positions(UpdateTime);