0% found this document useful (0 votes)
68 views1 page

CREATE DATABASE Car - Owner

The document creates a Car_Owner database with two tables - a Car table to store vehicle data with a primary key on the tag number, and an Owner_t table to store owner details with a primary key on the owner ID and a foreign key linking it to the Car table. It then populates the tables with some sample insert statements.

Uploaded by

Khalid Saleh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views1 page

CREATE DATABASE Car - Owner

The document creates a Car_Owner database with two tables - a Car table to store vehicle data with a primary key on the tag number, and an Owner_t table to store owner details with a primary key on the owner ID and a foreign key linking it to the Car table. It then populates the tables with some sample insert statements.

Uploaded by

Khalid Saleh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

CREATE DATABASE Car_Owner

USE [Car_Owner]
CREATE TABLE [dbo].[Car](
[Tag_No] [varchar](10) NOT NULL,
[Model] [varchar](25) NOT NULL,
[Color] [varchar](10) NOT NULL,
[Desc] [varchar](50) NULL,
CONSTRAINT [PK_Car] PRIMARY KEY CLUSTERED ([Tag No]))
GO

USE [Car_Owner]
CREATE TABLE [dbo].[Owner_t](
[Owner_ID] [varchar](12) NOT NULL,
[Owner_Name] [varchar](30) NOT NULL,
[Owner_Street] [varchar](25) NULL,
[Owner_City] [varchar](20) NULL,
[Owner_Country] [varchar](20) NULL,
[Owner_ZipCode] [varchar](6) NULL,
[Tag_No] [varchar](10) NULL,
CONSTRAINT [PK_Owner] PRIMARY KEY CLUSTERED ([Owner_ID]),
CONSTRAINT [FK_Owner] FOREIGN KEY ([Tag_No]) REFERENCES
[Car]([Tag_No]))
GO

USE [Car_Owner]
INSERT INTO Car VALUES ('SAN1','Toyota', 'Blue', 'Four Wheel
Drive')
INSERT INTO Car VALUES ('ADN2','Suzuki', 'Red', 'Family Car')
INSERT INTO Car VALUES ('TAIZ3','Honda', 'White', 'Civic')
GO
USE [Car_Owner]
INSERT INTO Owner_t VALUES ('Sami30','Sami', 'Hada',
'Sanaa','Yemen','00000','SAN1')
INSERT INTO Owner_t VALUES ('Waad100','Waad', 'Dairy',
'Sanaa','Yemen','00000','Taiz3')
GO

You might also like