80 likes | 191 Views
EMPLOYEE ( empid , name) DEPARTMENT( depid , post, empid ). Database Schema (1:1 Relationship). Empid. depid. manages. EMPOLYEE. Department. 1. 1. name. post. Empid. depid. manages. EMPOLYEE. Department. 1. 1. name. EMPLOYEE( empid , name, depid ) DEPARTMENR( depid , post).
E N D
EMPLOYEE (empid, name) DEPARTMENT(depid, post, empid ) Database Schema (1:1 Relationship) Empid depid manages EMPOLYEE Department 1 1 name post
Empid depid manages EMPOLYEE Department 1 1 name EMPLOYEE(empid, name, depid) DEPARTMENR(depid, post) post Database Schema (1:1 Relationship) or • NO new table is created. • FK can be added to either table.
EMPLOYEE (empid, name, depid ) DEPARTMENT(depid, post,) Database Schema (M:1 Relationship) Empid depid Works in EMPOLYEE Department M 1 name post
Empid depid Works in EMPOLYEE Department M 1 name post Database Schema (M:1 Relationship) EMPLOYEE (empid, name, depid ) DEPARTMENT(depid, post,) • FK should be added to “many” side. • Doesn’t matter for cardinalities.
sid date evid admission Student event M N sname class schoolyear grade evname Database Schema (M:N Relationship) STUDENT (sid, sname, class, classno) EVENT (evid, evname, grade, gender) How about admission?
sid date evid admission Student event M N sname class schoolyear grade evname Database Schema (M:N Relationship) STUDENT (sid, sname, class, classno) EVENT (evid, evname, grade, gender) • A new table is needed. • FK(s) should be placed in that new table. ADMISSION (sid, evid, date, schooyear)
Ex. Transform the E-R diagram into database schema standard_cost vid unit_cost mid supply VENDOR RAW_MATERIAL M N M vendor_name manufacture pid product_desc N PRODUCT unit_price
Standard_cost vid unit_cost mid supply VENDOR RAW_MATERIAL M N M vendor_name manufacture Pid VENDOR (vid, vendor_name) RAW_MATERIAL (mid, standard_code) PRODUCT (pid, product_desc, unit_price) SUPPLY (vid, mid, unit_cost) MANUFACTURE (pid, mid) product_desc PRODUCT N Unit_price