Вы находитесь на странице: 1из 3

COMSATS Institute of Information Technology,

Department of Computing

CSC271: Database Systems

Lab 07: Data Definition Language

Instructor: Dr. Khalid Latif

CSC271: Database Systems Page 1




Introduction
SQL provides a subset of commands, known as data definition language (DDL), for defining new
database schema. This subset includes CREATE TABLE command to define data structure for a new
table, its columns and domains.

Objectives
After performing this lab students should be able to:

1. Create database schema and create relation schemas using CREATE SCHEMA and
CREATE TABLE command.
2. Understand the differences between different SQL data-types and chose an appropriate type
in a given situation.

Tools/Software Requirement
MySQL Community Server 5.6
MySQL Workbench 6.1

Description

1. This lab assumes that MySQL Community Server is running and the query window is
open.

Lab Task
1. Implement SQL schema definition for creating a database for Alpha Auto Insurance.
2. Choose an appropriate domain for each attribute and an appropriate primary key (and
foreign key) for each relation.
3. The company currently manages following data in Excel files.
a) Persons (cnic, name, address, city, age)
b) Vehicles (registration number, district, maker, model, year, owner cnic)
i. Maker examples: Toyota, Honda
ii. Model examples: Corolla, Civic
c) Accidents (report number, registration number, date/time, location, region,
comments)
d) Damages (accident report number, body part, assessed amount, repair summary)
4. The company only insures certain vehicles manufactured by Toyota and Honda as they
think other manufacturer do not conform to necessary safety standards and features. So
the maker column in Vehicle table should be restricted to contain limited values. Hint:
Read about the ENUM datatype.
5. Insert at least couple of records in every relation.
CSC271: Database Systems Page 2


a) One of the persons should have CNIC value as 12345-1234567-1.
b) Registration year of some of vehicle should be 2012 or earlier and some others
after 2012.
c) Some of the accidents should be from Islamabad region.

Deliverable
Submit a PDF or plain-text document including the SQL queries to implement the database in
MySQL using the Workbench.

CSC271: Database Systems Page 3

Вам также может понравиться