Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
daaexample
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Manuel Vázquez Augusto
daaexample
Commits
4313de61
Commit
4313de61
authored
Mar 18, 2020
by
MvaugustoESEI
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ejercicio previo terminado DAAExample
parent
90d402d1
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
109 additions
and
9 deletions
+109
-9
mysql-with-inserts.sql
db/mysql-with-inserts.sql
+8
-0
mysql.sql
db/mysql.sql
+8
-0
DAAExampleApplication.java
src/main/java/es/uvigo/esei/daa/DAAExampleApplication.java
+3
-1
PeopleDAO.java
src/main/java/es/uvigo/esei/daa/dao/PeopleDAO.java
+1
-1
PeopleResource.java
src/main/java/es/uvigo/esei/daa/rest/PeopleResource.java
+3
-2
people.js
src/main/webapp/js/view/people.js
+12
-0
main.html
src/main/webapp/main.html
+22
-0
AuthorizationFilter.java
...t/java/es/uvigo/esei/daa/filters/AuthorizationFilter.java
+6
-1
IntegrationTestSuite.java
...t/java/es/uvigo/esei/daa/suites/IntegrationTestSuite.java
+3
-1
UnitTestSuite.java
src/test/java/es/uvigo/esei/daa/suites/UnitTestSuite.java
+3
-1
dataset-add.xml
src/test/resources/datasets/dataset-add.xml
+5
-0
dataset-delete.xml
src/test/resources/datasets/dataset-delete.xml
+6
-0
dataset-modify.xml
src/test/resources/datasets/dataset-modify.xml
+6
-0
dataset.dtd
src/test/resources/datasets/dataset.dtd
+8
-1
dataset.xml
src/test/resources/datasets/dataset.xml
+5
-0
hsqldb-drop.sql
src/test/resources/db/hsqldb-drop.sql
+2
-1
hsqldb.sql
src/test/resources/db/hsqldb.sql
+8
-0
No files found.
db/mysql-with-inserts.sql
View file @
4313de61
...
@@ -14,6 +14,14 @@ CREATE TABLE `daaexample`.`users` (
...
@@ -14,6 +14,14 @@ CREATE TABLE `daaexample`.`users` (
PRIMARY
KEY
(
`login`
)
PRIMARY
KEY
(
`login`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
TABLE
`daaexample`
.
`pets`
(
`id`
int
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
50
)
NOT
NULL
,
`owner_id`
int
NOT
NULL
,
PRIMARY
KEY
(
`id`
),
FOREIGN
KEY
(
`owner_id`
)
REFERENCES
`people`
(
`id`
)
ON
DELETE
CASCADE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
USER
'daa'
@
'localhost'
IDENTIFIED
BY
'daa'
;
CREATE
USER
'daa'
@
'localhost'
IDENTIFIED
BY
'daa'
;
GRANT
ALL
ON
`daaexample`
.
*
TO
'daa'
@
'localhost'
;
GRANT
ALL
ON
`daaexample`
.
*
TO
'daa'
@
'localhost'
;
...
...
db/mysql.sql
View file @
4313de61
...
@@ -14,5 +14,13 @@ CREATE TABLE `daaexample`.`users` (
...
@@ -14,5 +14,13 @@ CREATE TABLE `daaexample`.`users` (
PRIMARY
KEY
(
`login`
)
PRIMARY
KEY
(
`login`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
TABLE
`daaexample`
.
`pets`
(
`id`
int
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
50
)
NOT
NULL
,
`owner_id`
int
NOT
NULL
,
PRIMARY
KEY
(
`id`
),
FOREIGN
KEY
(
`owner_id`
)
REFERENCES
`people`
(
`id`
)
ON
DELETE
CASCADE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
USER
'daa'
@
'localhost'
IDENTIFIED
BY
'daa'
;
CREATE
USER
'daa'
@
'localhost'
IDENTIFIED
BY
'daa'
;
GRANT
ALL
ON
`daaexample`
.
*
TO
'daa'
@
'localhost'
;
GRANT
ALL
ON
`daaexample`
.
*
TO
'daa'
@
'localhost'
;
src/main/java/es/uvigo/esei/daa/DAAExampleApplication.java
View file @
4313de61
...
@@ -11,6 +11,7 @@ import javax.ws.rs.ApplicationPath;
...
@@ -11,6 +11,7 @@ import javax.ws.rs.ApplicationPath;
import
javax.ws.rs.core.Application
;
import
javax.ws.rs.core.Application
;
import
es.uvigo.esei.daa.rest.PeopleResource
;
import
es.uvigo.esei.daa.rest.PeopleResource
;
import
es.uvigo.esei.daa.rest.PetsResource
;
import
es.uvigo.esei.daa.rest.UsersResource
;
import
es.uvigo.esei.daa.rest.UsersResource
;
/**
/**
...
@@ -26,7 +27,8 @@ public class DAAExampleApplication extends Application {
...
@@ -26,7 +27,8 @@ public class DAAExampleApplication extends Application {
public
Set
<
Class
<?>>
getClasses
()
{
public
Set
<
Class
<?>>
getClasses
()
{
return
Stream
.
of
(
return
Stream
.
of
(
PeopleResource
.
class
,
PeopleResource
.
class
,
UsersResource
.
class
UsersResource
.
class
,
PetsResource
.
class
).
collect
(
toSet
());
).
collect
(
toSet
());
}
}
...
...
src/main/java/es/uvigo/esei/daa/dao/PeopleDAO.java
View file @
4313de61
package
es
.
uvigo
.
esei
.
daa
.
dao
;
package
es
.
uvigo
.
esei
.
daa
.
dao
;
import
java.sql.Statement
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
...
...
src/main/java/es/uvigo/esei/daa/rest/PeopleResource.java
View file @
4313de61
...
@@ -17,6 +17,7 @@ import javax.ws.rs.core.Response;
...
@@ -17,6 +17,7 @@ import javax.ws.rs.core.Response;
import
es.uvigo.esei.daa.dao.DAOException
;
import
es.uvigo.esei.daa.dao.DAOException
;
import
es.uvigo.esei.daa.dao.PeopleDAO
;
import
es.uvigo.esei.daa.dao.PeopleDAO
;
import
es.uvigo.esei.daa.entities.Person
;
import
es.uvigo.esei.daa.entities.Person
;
import
es.uvigo.esei.daa.dao.PetsDAO
;
/**
/**
* REST resource for managing people.
* REST resource for managing people.
...
@@ -34,11 +35,11 @@ public class PeopleResource {
...
@@ -34,11 +35,11 @@ public class PeopleResource {
* Constructs a new instance of {@link PeopleResource}.
* Constructs a new instance of {@link PeopleResource}.
*/
*/
public
PeopleResource
()
{
public
PeopleResource
()
{
this
(
new
PeopleDAO
());
this
(
new
PeopleDAO
()
,
new
PetsDAO
()
);
}
}
// Needed for testing purposes
// Needed for testing purposes
PeopleResource
(
PeopleDAO
dao
)
{
PeopleResource
(
PeopleDAO
dao
,
PetsDAO
petsDao
)
{
this
.
dao
=
dao
;
this
.
dao
=
dao
;
}
}
...
...
src/main/webapp/js/view/people.js
View file @
4313de61
...
@@ -106,6 +106,13 @@ var PeopleView = (function() {
...
@@ -106,6 +106,13 @@ var PeopleView = (function() {
}
}
};
};
this
.
listPets
=
function
(
id
){
var
person
=
this
.
getPersonInRow
(
id
);
var
petsView
=
new
PetsView
(
new
PetsDAO
(
id
),
'modal-pets'
,
person
.
name
+
' '
+
person
.
surname
);
petsView
.
init
();
$
(
'#modal-pets'
).
modal
(
'show'
);
};
this
.
isEditing
=
function
()
{
this
.
isEditing
=
function
()
{
return
$
(
formQuery
+
' input[name="id"]'
).
val
()
!=
""
;
return
$
(
formQuery
+
' input[name="id"]'
).
val
()
!=
""
;
};
};
...
@@ -166,6 +173,7 @@ var PeopleView = (function() {
...
@@ -166,6 +173,7 @@ var PeopleView = (function() {
<td class="name col-sm-4">'
+
person
.
name
+
'</td>
\
<td class="name col-sm-4">'
+
person
.
name
+
'</td>
\
<td class="surname col-sm-5">'
+
person
.
surname
+
'</td>
\
<td class="surname col-sm-5">'
+
person
.
surname
+
'</td>
\
<td class="col-sm-3">
\
<td class="col-sm-3">
\
<a class="pets btn btn-primary" href="#">Mascotas</a>
\
<a class="edit btn btn-primary" href="#">Editar</a>
\
<a class="edit btn btn-primary" href="#">Editar</a>
\
<a class="delete btn btn-warning" href="#">Eliminar</a>
\
<a class="delete btn btn-warning" href="#">Eliminar</a>
\
</td>
\
</td>
\
...
@@ -184,6 +192,10 @@ var PeopleView = (function() {
...
@@ -184,6 +192,10 @@ var PeopleView = (function() {
$
(
'#person-'
+
person
.
id
+
' a.delete'
).
click
(
function
()
{
$
(
'#person-'
+
person
.
id
+
' a.delete'
).
click
(
function
()
{
self
.
deletePerson
(
person
.
id
);
self
.
deletePerson
(
person
.
id
);
});
});
$
(
'#person-'
+
person
.
id
+
' a.pets'
).
click
(
function
()
{
self
.
listPets
(
person
.
id
);
});
};
};
var
appendToTable
=
function
(
person
)
{
var
appendToTable
=
function
(
person
)
{
...
...
src/main/webapp/main.html
View file @
4313de61
...
@@ -26,10 +26,32 @@
...
@@ -26,10 +26,32 @@
</div>
</div>
</div>
</div>
<div
class=
"modal fade"
id=
"modal-pets"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"modal-pets-title"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"modal-pets-title"
></h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body"
id=
"modal-pets-body"
>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
Cerrar
</button>
</div>
</div>
</div>
</div>
<script
type=
"text/javascript"
<script
type=
"text/javascript"
src=
"http://code.jquery.com/jquery-2.2.4.min.js"
></script>
src=
"http://code.jquery.com/jquery-2.2.4.min.js"
></script>
<script
type=
"text/javascript"
src=
"js/boostrap/js/bootstrap.js"
></script>
<script
type=
"text/javascript"
src=
"js/dao/people.js"
></script>
<script
type=
"text/javascript"
src=
"js/dao/people.js"
></script>
<script
type=
"text/javascript"
src=
"js/view/people.js"
></script>
<script
type=
"text/javascript"
src=
"js/view/people.js"
></script>
<script
type=
"text/javascript"
src=
"js/dao/pets.js"
></script>
<script
type=
"text/javascript"
src=
"js/view/pets.js"
></script>
<script
type=
"text/javascript"
src=
"js/login.js"
></script>
<script
type=
"text/javascript"
src=
"js/login.js"
></script>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
$
(
document
).
ready
(
...
...
src/test/java/es/uvigo/esei/daa/filters/AuthorizationFilter.java
View file @
4313de61
...
@@ -54,7 +54,7 @@ public class AuthorizationFilter implements ContainerRequestFilter {
...
@@ -54,7 +54,7 @@ public class AuthorizationFilter implements ContainerRequestFilter {
if
(
this
.
dao
.
checkLogin
(
userPass
[
0
],
userPass
[
1
]))
{
if
(
this
.
dao
.
checkLogin
(
userPass
[
0
],
userPass
[
1
]))
{
final
User
user
=
this
.
dao
.
get
(
userPass
[
0
]);
final
User
user
=
this
.
dao
.
get
(
userPass
[
0
]);
if
(
isPeoplePath
(
requestContext
)
&&
!
user
.
getRole
().
equals
(
"ADMIN"
))
{
if
(
(
isPeoplePath
(
requestContext
)
||
isPetsPath
(
requestContext
)
)
&&
!
user
.
getRole
().
equals
(
"ADMIN"
))
{
requestContext
.
abortWith
(
createResponse
());
requestContext
.
abortWith
(
createResponse
());
}
else
{
}
else
{
requestContext
.
setSecurityContext
(
new
UserSecurityContext
(
user
));
requestContext
.
setSecurityContext
(
new
UserSecurityContext
(
user
));
...
@@ -76,6 +76,11 @@ public class AuthorizationFilter implements ContainerRequestFilter {
...
@@ -76,6 +76,11 @@ public class AuthorizationFilter implements ContainerRequestFilter {
return
!
pathSegments
.
isEmpty
()
&&
pathSegments
.
get
(
0
).
getPath
().
equals
(
"people"
);
return
!
pathSegments
.
isEmpty
()
&&
pathSegments
.
get
(
0
).
getPath
().
equals
(
"people"
);
}
}
private
static
boolean
isPetsPath
(
ContainerRequestContext
context
)
{
final
List
<
PathSegment
>
pathSegments
=
context
.
getUriInfo
().
getPathSegments
();
return
!
pathSegments
.
isEmpty
()
&&
pathSegments
.
get
(
2
).
getPath
().
equals
(
"pets"
);
}
private
static
Response
createResponse
()
{
private
static
Response
createResponse
()
{
return
Response
.
status
(
Status
.
UNAUTHORIZED
)
return
Response
.
status
(
Status
.
UNAUTHORIZED
)
.
header
(
HttpHeaders
.
WWW_AUTHENTICATE
,
"Basic realm=\"DAAExample\""
)
.
header
(
HttpHeaders
.
WWW_AUTHENTICATE
,
"Basic realm=\"DAAExample\""
)
...
...
src/test/java/es/uvigo/esei/daa/suites/IntegrationTestSuite.java
View file @
4313de61
...
@@ -5,11 +5,13 @@ import org.junit.runners.Suite;
...
@@ -5,11 +5,13 @@ import org.junit.runners.Suite;
import
org.junit.runners.Suite.SuiteClasses
;
import
org.junit.runners.Suite.SuiteClasses
;
import
es.uvigo.esei.daa.rest.PeopleResourceTest
;
import
es.uvigo.esei.daa.rest.PeopleResourceTest
;
import
es.uvigo.esei.daa.rest.PetsResourceTest
;
import
es.uvigo.esei.daa.rest.UsersResourceTest
;
import
es.uvigo.esei.daa.rest.UsersResourceTest
;
@SuiteClasses
({
@SuiteClasses
({
PeopleResourceTest
.
class
,
PeopleResourceTest
.
class
,
UsersResourceTest
.
class
UsersResourceTest
.
class
,
PetsResourceTest
.
class
})
})
@RunWith
(
Suite
.
class
)
@RunWith
(
Suite
.
class
)
public
class
IntegrationTestSuite
{
public
class
IntegrationTestSuite
{
...
...
src/test/java/es/uvigo/esei/daa/suites/UnitTestSuite.java
View file @
4313de61
...
@@ -5,9 +5,11 @@ import org.junit.runners.Suite;
...
@@ -5,9 +5,11 @@ import org.junit.runners.Suite;
import
org.junit.runners.Suite.SuiteClasses
;
import
org.junit.runners.Suite.SuiteClasses
;
import
es.uvigo.esei.daa.entities.PersonUnitTest
;
import
es.uvigo.esei.daa.entities.PersonUnitTest
;
import
es.uvigo.esei.daa.entities.PetUnitTest
;
@SuiteClasses
({
@SuiteClasses
({
PersonUnitTest
.
class
PersonUnitTest
.
class
,
PetUnitTest
.
class
})
})
@RunWith
(
Suite
.
class
)
@RunWith
(
Suite
.
class
)
public
class
UnitTestSuite
{
public
class
UnitTestSuite
{
...
...
src/test/resources/datasets/dataset-add.xml
View file @
4313de61
...
@@ -16,4 +16,9 @@
...
@@ -16,4 +16,9 @@
<users
login=
"admin"
password=
"713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca"
role=
"ADMIN"
/>
<users
login=
"admin"
password=
"713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca"
role=
"ADMIN"
/>
<users
login=
"normal"
password=
"7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83"
role=
"USER"
/>
<users
login=
"normal"
password=
"7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83"
role=
"USER"
/>
<pets
id=
"1"
name=
"Micifu"
owner_id=
"1"
/>
<pets
id=
"2"
name=
"Tobi"
owner_id=
"1"
/>
<pets
id=
"3"
name=
"Guantes"
owner_id=
"1"
/>
<pets
id=
"4"
name=
"Pecas"
owner_id=
"1"
/>
</dataset>
</dataset>
\ No newline at end of file
src/test/resources/datasets/dataset-delete.xml
View file @
4313de61
...
@@ -14,4 +14,10 @@
...
@@ -14,4 +14,10 @@
<users
login=
"admin"
password=
"713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca"
role=
"ADMIN"
/>
<users
login=
"admin"
password=
"713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca"
role=
"ADMIN"
/>
<users
login=
"normal"
password=
"7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83"
role=
"USER"
/>
<users
login=
"normal"
password=
"7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83"
role=
"USER"
/>
<pets
id=
"1"
name=
"Micifu"
owner_id=
"1"
/>
<pets
id=
"2"
name=
"Tobi"
owner_id=
"1"
/>
<pets
id=
"3"
name=
"Guantes"
owner_id=
"1"
/>
<pets
id=
"4"
name=
"Pecas"
owner_id=
"1"
/>
</dataset>
</dataset>
\ No newline at end of file
src/test/resources/datasets/dataset-modify.xml
View file @
4313de61
...
@@ -15,4 +15,10 @@
...
@@ -15,4 +15,10 @@
<users
login=
"admin"
password=
"713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca"
role=
"ADMIN"
/>
<users
login=
"admin"
password=
"713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca"
role=
"ADMIN"
/>
<users
login=
"normal"
password=
"7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83"
role=
"USER"
/>
<users
login=
"normal"
password=
"7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83"
role=
"USER"
/>
<pets
id=
"1"
name=
"Micifu"
owner_id=
"1"
/>
<pets
id=
"2"
name=
"Tobi"
owner_id=
"1"
/>
<pets
id=
"3"
name=
"Guantes"
owner_id=
"1"
/>
<pets
id=
"4"
name=
"Pecas"
owner_id=
"1"
/>
</dataset>
</dataset>
\ No newline at end of file
src/test/resources/datasets/dataset.dtd
View file @
4313de61
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT dataset (people*, users*)>
<!ELEMENT dataset (people*, users*
, pets*
)>
<!ELEMENT people EMPTY>
<!ELEMENT people EMPTY>
<!ELEMENT users EMPTY>
<!ELEMENT users EMPTY>
<!ELEMENT pets EMPTY>
<!ATTLIST people
<!ATTLIST people
id CDATA #IMPLIED
id CDATA #IMPLIED
name CDATA #IMPLIED
name CDATA #IMPLIED
...
@@ -12,3 +13,9 @@
...
@@ -12,3 +13,9 @@
password CDATA #IMPLIED
password CDATA #IMPLIED
role CDATA #IMPLIED
role CDATA #IMPLIED
>
>
<!ATTLIST pets
id CDATA #IMPLIED
name CDATA #IMPLIED
owner_id CDATA #IMPLIED
>
src/test/resources/datasets/dataset.xml
View file @
4313de61
...
@@ -15,4 +15,9 @@
...
@@ -15,4 +15,9 @@
<users
login=
"admin"
password=
"713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca"
role=
"ADMIN"
/>
<users
login=
"admin"
password=
"713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65baca"
role=
"ADMIN"
/>
<users
login=
"normal"
password=
"7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83"
role=
"USER"
/>
<users
login=
"normal"
password=
"7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83"
role=
"USER"
/>
<pets
id=
"1"
name=
"Micifu"
owner_id=
"1"
/>
<pets
id=
"2"
name=
"Tobi"
owner_id=
"1"
/>
<pets
id=
"3"
name=
"Guantes"
owner_id=
"1"
/>
<pets
id=
"4"
name=
"Pecas"
owner_id=
"1"
/>
</dataset>
</dataset>
\ No newline at end of file
src/test/resources/db/hsqldb-drop.sql
View file @
4313de61
DROP
TABLE
Pets
IF
EXISTS
;
DROP
TABLE
People
IF
EXISTS
;
DROP
TABLE
People
IF
EXISTS
;
DROP
TABLE
Users
IF
EXISTS
;
DROP
TABLE
Users
IF
EXISTS
;
\ No newline at end of file
src/test/resources/db/hsqldb.sql
View file @
4313de61
...
@@ -11,3 +11,11 @@ CREATE TABLE users (
...
@@ -11,3 +11,11 @@ CREATE TABLE users (
role
VARCHAR
(
5
)
NOT
NULL
,
role
VARCHAR
(
5
)
NOT
NULL
,
PRIMARY
KEY
(
login
)
PRIMARY
KEY
(
login
)
);
);
CREATE
TABLE
pets
(
id
INTEGER
GENERATED
BY
DEFAULT
AS
IDENTITY
(
START
WITH
1
,
INCREMENT
BY
1
)
NOT
NULL
,
name
varchar
(
50
)
NOT
NULL
,
owner_id
int
NOT
NULL
,
PRIMARY
KEY
(
id
),
FOREIGN
KEY
(
owner_id
)
REFERENCES
people
(
id
)
ON
DELETE
CASCADE
);
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment