I started database a few weeks back so im basically a potato right now! Anyway i encountered this problem in the exercises but i wasnt sure on how to do some of the steps.
I have to create a table in SQL with these:
USER(SSN, Name, Surname, YearOfBirth)
CONTENT (CodC, Category, Duration, Title, Description*)
RATING (SSN, CodC, Date, Evaluation)
The primary keys are shown but i dont know how to underline in here. I also had these Notes to follow:
• CodC is an incremental positive integer identifer (1, 2, etc.).
• Duration is in minutes.
• Evaluation contains the level of satisfaction expressed on a scale from 1 to 10.
I know I have not completed the creation of the tables since i have to define the Primary Keys and Foreign Keys but that extremely easy to do but right now but what i need help with is HOW do i write the Duration to be explicitly in minutes and for CodC to have incremental positive integer identifier. Can you help me?
SO what i did was:
CREATE TABLE User (
SSN CHAR (20) NOT NULL,
Name CHAR (50) NOT NULL,
Surname CHAR (50) NOT NULl,
YearOfBirth Year NOT NULL,
)
CREATE TABLE Content (
CodC int(10) IDENTITY(1,1), // the identity thing i copy-pasted it from the net
Category varchar(30) NOT NULL,
Duration smallint(20) NOT NULL,
Title varchar(20) NOT NULL,
Description varchar(20) NOT NULL,
)
CREATE TABLE Rating(
SSN CHAR (20) NOT NULL,
CodC int(10) NOT NULL,
Date varchar(20) NOT NULL,
Evaluation smallint(20) NOT NULL,
CONSTRAINT lev_constr CHECK ( Evaluation >=1 AND Evaluation <=10)
);