I am a beginner in this field and I have some mistakes in ((codes)) who can tell me what my mistakes.
Physical model (1)
Employee (SSN, Salary, Phone)
CREATE TABLE Employee (SSN integer PRIMRY KEY, Salary integer, phone integer);
Department(DNO, dname, Budget, ssn_employee)
CREATE TABLE Department(DNO integer, dname varchar(10 )Budget Integer, ssn_employee int, CONSTRAINT pk_Department PRIMARY KEY (DNO) ,FOREIGN KEY (ssn_employee) REFERENCES employee(ssn_employee) ON UPDATE CASCADE ON DELETE SET NULL );
Child(IDChild, Name, Age, ssn_employee)
CREATE TABLE Child( IDChild Integer, Name varchar(40), Age Integer, ssn_employee Integer
CONSTRAINT pk_Child PRIMARY KEY (IDChild),
FOREIGN KEY (ssn_employee) REFERENCES employee(ssn_employee) ON UPDATE CASCADE ON DELETE SET NULL
);
Employee_Department(SSN_DNO)
CREATE TABLE Employee_Department ( SSN Integer, DNO Integer,
FOREIGN KEY (SSN) REFERENCES employee(SSN) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (DNO) REFERENCES department(dnumber) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT pk_sd PRIMARY KEY (SSN,DNO)
);
Physical model (2)
Artist(IDArtist, Name, Birthplace, Age, style)
CREATE TABLE Artist( IDArtist Integer PRIMARY KEY,Name varchar(30), Birthplace varchar(20) Age Integer, Style Integer );
Customer(IDCustomer, Name, Address)CREATE TABLE Customer( IDCustomer Integer PRIMARY KEY, Name varchar(30), Address varchar(50) );
Artwork(IDArtwork, Title, Type, Price)CREATE TABLE Artwork( IDArtwork Integer PRIMARY KEY, Title varchar(40), Type varchar(15), Price Integer );
Group(IDGroup, Name)CREATE TABLE Group( IDGroup Integer PRIMARY KEY, Name varchar(30)
);
Artist_Artwork(IDArtist, IDArtwork)
CREATE TABLE Artist_Artwork( IDArtist Integer, IDArtwork Integer, FOREIGN KEY (IDArtist) REFERENCES Artist(IDArtist) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (IDArtwork) REFERENCES Artwork(IDArtwork) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT pk_Artist_Artwork PRIMARY KEY (IDArtist, IDArtowork) );
Artwork_Group(IDArtwork, IDGroup) CREATE TABLE Artwork_Group( IDArtwork Integer,
IDGroup Integer,
FOREIGN KEY (IDArtwork) REFERENCES Artwork(IDArtwork) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (IDGroup) REFERENCES Group(IDGroup) ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT pk_Artwork_Group PRIMARY KEY (IDArtwork, IDGroup)
);
Customer_Artwork(IDCustomer, IDArtwork)
CREATE TABLE Customer_Artwork (
IDCustomer Integer,
IDArtwork Integer,
FOREIGN KEY (IDCustomer) REFERENCES Customer(IDCustomer) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (IDArtwork) REFERENCES Artwork(IDArtwork) ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT pk_Customer_Artwork PRIMARY KEY (IDCustomer, IDArtwork)
);
Physical model (3)
Employee(IDEmployee, Name, Birthplace, Age, IDManager)
CREATE TABLE Employee(
IDEmployee Integer,
Name vargar(15),
Birthplace varchar(20),
Age Integer,
IDManager Integer
CONSTRAINT pk_Employee PRIMARY KEY (IDEmployee),
FOREIGN KEY (IDManager) REFERENCES Manager(IDManager) ON UPDATE CASCADE ON DELETE SET NULL
);
Product(IDProduct, Type, Price)
CREATE TABLE Product(
IDProduct Integer PRIMARY KEY,
Type varchar(25),
Price Integer
);
Employee_Product(IDEmployee, IDP)
CREATE TABLE Employee_Product(
IDEmployee Integer,
IDP Integer,
FOREIGN KEY (IDEmployee) REFRENCES Employee(IDEmployee)ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (IDP) REFRENCES Product(IDProduct)ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT pk_Employee_Product PRIMARY KEY (IDEmployee, IDProduct)
);
Product_Product(IDProduct_Composee, IDProduct_Composer)
CREATE TABLE Product_Product(
IDProduct_Composee Integer,
IDProduct_Composer Integer,
FOREIGN KEY (IDproduct_Composee) REFRENCES EProduct_Composee(IDproduct_Composee)ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (IDproduct_Composee) REFRENCES EProduct_Composee(IDproduct_Composee)ON UPDATE CASCADE ON DELETE CASCADE,
);