设计 3NF 数据库
Designing 3NF Database
我正在为保险管理系统设计一个 3nf(关系)数据库。
以下是我的简介;
The system must provides means of associating their customers and cars with recorded accidents. Each customer has name, address and can have one or mpre driving licenses. One customer can own 1 or more cars. A car has a reg no, model and year of manufacture. Each car has associated with it zero to any number of recorded accidents. Each accident has a report number, date, location and an amount of damage.
I have complied the following tables:
CREATE TABLE Customer(CID int primary key, Address varchar (50),Name varchar (50));
CREATE TABLE Driving_Lisc (CID int, Lisc_NO int, primary key);
CREATE TABLE Car(Reg_No varchar (20) primary key, Model nvarchar (20),year int)
CREATE TABLE Owns(CID int, Reg_No nvarchar(20) composite key)
CREATE Accident (Reported_No int primary key, Location varchar (40), date date)
Participated(CID int, Reg_No nvarchar(20), Reported No int primary key, damage Amount float)
我想看看我是否正确编译了这些数据库以完成 SQLite 查询。
答案是 NO 即代码将无法使用 SQLite,因为 :-
在 CREATE TABLE Driving_Lisc (CID int, Lisc_NO int, primary key);
中有一个无关的 ,
分隔 primary key
或者列名和类型在逗号后面被省略.
在 CREATE TABLE Owns(CID int, Reg_No nvarchar(20) composite key)
composite 中不是 SQLite 关键字,应该在列类型 ('nvarchar(20)') 之后。
在 CREATE Accident (Reported_No int primary key, Location varchar (40), date date)
中,您没有指定要创建的内容。你可能想要 CREATE TABLE Accident (Reported_No int primary key, Location varchar (40), date date)
使用 Participated(CID int, Reg_No nvarchar(20), Reported No int primary key, damage Amount float)
将导致语法错误,因为没有 SQL 关键字指示要做什么。你可能想要 CREATE TABLE Participated(CID int, Reg_No nvarchar(20), Reported No int primary key, damage Amount float)
我正在为保险管理系统设计一个 3nf(关系)数据库。
以下是我的简介;
The system must provides means of associating their customers and cars with recorded accidents. Each customer has name, address and can have one or mpre driving licenses. One customer can own 1 or more cars. A car has a reg no, model and year of manufacture. Each car has associated with it zero to any number of recorded accidents. Each accident has a report number, date, location and an amount of damage. I have complied the following tables:
CREATE TABLE Customer(CID int primary key, Address varchar (50),Name varchar (50));
CREATE TABLE Driving_Lisc (CID int, Lisc_NO int, primary key);
CREATE TABLE Car(Reg_No varchar (20) primary key, Model nvarchar (20),year int)
CREATE TABLE Owns(CID int, Reg_No nvarchar(20) composite key)
CREATE Accident (Reported_No int primary key, Location varchar (40), date date)
Participated(CID int, Reg_No nvarchar(20), Reported No int primary key, damage Amount float)
我想看看我是否正确编译了这些数据库以完成 SQLite 查询。
答案是 NO 即代码将无法使用 SQLite,因为 :-
在 CREATE TABLE Driving_Lisc (CID int, Lisc_NO int, primary key);
中有一个无关的 ,
分隔 primary key
或者列名和类型在逗号后面被省略.
在 CREATE TABLE Owns(CID int, Reg_No nvarchar(20) composite key)
composite 中不是 SQLite 关键字,应该在列类型 ('nvarchar(20)') 之后。
在 CREATE Accident (Reported_No int primary key, Location varchar (40), date date)
中,您没有指定要创建的内容。你可能想要 CREATE TABLE Accident (Reported_No int primary key, Location varchar (40), date date)
使用 Participated(CID int, Reg_No nvarchar(20), Reported No int primary key, damage Amount float)
将导致语法错误,因为没有 SQL 关键字指示要做什么。你可能想要 CREATE TABLE Participated(CID int, Reg_No nvarchar(20), Reported No int primary key, damage Amount float)