Професионална програма
Loading...
+ Нов въпрос
Katsy.Kr avatar Katsy.Kr 0 Точки

1 зад. DDL- https://judge.softuni.org/Contests/Practice/Index/2866#0

Имам проблем с тази база. Дава ми грешки в таблици:  Reports, Categories, Employees. В judge  имам резултат от 22/30.

Някой може ли да погледне?

Благодаря!!!

 

CREATE DATABASE [Service]

USE [Service]

GO

 

CREATE TABLE Users (

       Id INT PRIMARY KEY IDENTITY NOT NULL,

       Username VARCHAR(30) NOT NULL UNIQUE,

       [Password] VARCHAR(50) NOT NULL,

       [Name] VARCHAR(50),

       Birthdate DATETIME2,

       Age INT NOT NULL

       CHECK(LEN(Age) > 14 AND LEN(Age) <= 110),

       Email VARCHAR(50) NOT NULL

);

 

CREATE TABLE Departments (

       Id INT PRIMARY KEY IDENTITY NOT NULL,

       [Name] VARCHAR(50) NOT NULL,

);

 

CREATE TABLE Employees (

       Id INT PRIMARY KEY IDENTITY NOT NULL,

       FirstName VARCHAR(25),

       LastName VARCHAR(25),

       Birthdate DATETIME2,

       Age INT NOT NULL

       CHECK(LEN(Age) > 18 AND LEN(Age) <= 110),

       DepartmentId INT FOREIGN KEY REFERENCES Departments(Id)

);

 

CREATE TABLE Categories (

       Id INT PRIMARY KEY IDENTITY NOT NULL,

       [Name] VARCHAR(50) NOT NULL,

       DepartmentId INT FOREIGN KEY REFERENCES Departments(Id) NOT NULL

);

 

CREATE TABLE [Status] (

       Id INT PRIMARY KEY IDENTITY NOT NULL,

       [Label] VARCHAR(30) NOT NULL

);

 

CREATE TABLE Reports (

       Id INT PRIMARY KEY IDENTITY NOT NULL,

       CategoryId INT FOREIGN KEY REFERENCES Categories(Id) NOT NULL,

       StatusId INT FOREIGN KEY REFERENCES [Status](Id) NOT NULL,

       OpenDate DATETIME2 NOT NULL,

       CloseDate DATETIME2,

       [Description] VARCHAR(200) NOT NULL,

       UserId INT FOREIGN KEY REFERENCES Users(Id) NOT NULL,

       EmployeeId INT FOREIGN KEY REFERENCES Employees(Id)

);

Тагове:
0
Databases Basics
icowwww avatar icowwww 1688 Точки

Здравей,

Проверките за Age са не правилни: CHECK(LEN(Age) > 14 AND LEN(Age) <= 110)

При SELECT LEN(25) изкарва резултат 2, защото LEN e дължината. https://www.techonthenet.com/sql_server/functions/len.php

Направи ги на CHECK(Age > 18 AND Age <= 110) в Employees и Users и ще мине

0
16/10/2021 21:50:57
Katsy.Kr avatar Katsy.Kr 0 Точки

Здеавей отново,

Оправих го, благодаря многоyeswink

0