Files
cloud-cap-samples/packages/bookshop/db/schema.cds
Elena Oresharova b7aee4e0e0 Add code for unit 2
2020-02-10 16:26:31 +01:00

46 lines
1.1 KiB
Plaintext

namespace sap.capire.bookshop;
using { Currency, managed, cuid } from '@sap/cds/common';
using { sap.capire.bookshop.Products } from './products';
/*
entity Books : managed {
key ID : Integer;
title : localized String(111);
descr : localized String(1111);
author : Association to Authors;
stock : Integer;
price : Decimal(9,2);
currency : Currency;
} */
entity Books : Products {
author : Association to Authors;
}
entity Magazines : Products {
publisher : String;
}
entity Authors : managed {
key ID : Integer;
name : String(111);
dateOfBirth : Date;
dateOfDeath : Date;
placeOfBirth : String;
placeOfDeath : String;
books : Association to many Books on books.author = $self;
}
entity Orders : cuid, managed {
OrderNo : String @title:'Order Number'; //> readable key
Items : Composition of many OrderItems on Items.parent = $self;
total : Decimal(9,2) @readonly;
currency : Currency;
}
entity OrderItems : cuid {
parent : Association to Orders;
book : Association to Books;
amount : Integer;
netAmount : Decimal(9,2);
}