entity-relationship

Core Data simple relationship in code

為{幸葍}努か 提交于 2019-12-03 14:07:06
问题 I am a cocoa newbie trying to create an iPhone app including Core Data. My problem is this: I have a little app running now with a single entity called Playlist that I display in a table view and can add and delete entries in. I have these in my PlayerAppDelegate: playlistManagedObjectModel playlistListManagedObjectContext playlistListPersistentStoreCoordinator Adding entity with: Playlist *playlist = (Playlist *)[NSEntityDescription insertNewObjectForEntityForName:@"Playlist"

Entity Framework - relationship with fake Foreign Key (no foreign key in the db)

依然范特西╮ 提交于 2019-12-03 14:01:58
I have many tables that have TextID column which refers to the translation table. Translation table needs also LanguageID to get translated text in desired language. My problem is that I do not have LanguageID in my database, it is predefined in the system and I do not know how can I define it using Fluent API, i.e this can be my model: public partial class MyEntity { public short ID { get; set; } public Nullable<int> TextID { get; set; } [NotMapped] public Nullable<int> LanguageID { get; set; } public virtual TEXT_TRANSLATION Translation { get; set; } } And the translation table: public

Followup: how to model discount on items in a database?

ε祈祈猫儿з 提交于 2019-12-03 13:46:18
问题 I am building an ecommerce site and would like to offer discounts on certain items for a limited time. I would like to display how much discount we are offering per product. Hence, I need two values per product, original price and the discounted price for the given duration. This is in followup to an answer for the question I asked Schema: Product productId Name ProductPricing productId (FK) startDateTimeStamp endDateTimeStamp price original price only applicable if we use approach A (comes

SQLAlchemy ER diagram in python 3

蹲街弑〆低调 提交于 2019-12-03 13:21:37
Does anyone know a way to make an ER diagram from SQLAlchemy models in python 3. I found sqlalchemy_schemadisplay, which is python 2 because of pydot and ERAlchemy which is also python 2 only. You can try eralchemy . import matplotlib.pyplot as plt import matplotlib.image as mpimg import pandas as pd from eralchemy import render_er from sqlalchemy import (MetaData, Table, Column) metadata = MetaData() # create your own model .... users = Table('users', metadata, Column('user_id', Integer(), primary_key=True), Column('username', String(15), nullable=False, unique=True), ) orders = Table('orders

how to model discount on items in a database?

自闭症网瘾萝莉.ら 提交于 2019-12-03 12:30:14
问题 I am building an ecommerce site and would like to offer discounts on certain items for a limited time. My Product table (MySQL) looks like this: Product - productId - Name - Weight - Price (price as on the cover of the item) Should I make another table for deals: Deals - dealID - productID (Foreign Key) - discount (fractional value: percentage) - description For retrieving items: q1: Find all products in products with productID = all the productIDs in deals table q2: Update the price with

Recommendation for a good entity relationship diagram building tool for occasional usage? [closed]

老子叫甜甜 提交于 2019-12-03 12:21:38
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Freeware is a plus. Could you also describe with one sentence why it should be good enough for occasional usage? Edit: You might check this cool link , providing more info about entity relationship diagrams and tools Edit: For the chosen answer couple of tips - click on entity even it looks like circle and type

Using Entity Framework with historical data

二次信任 提交于 2019-12-03 11:08:49
I'm building a windows application in .Net 4.0 to create and organize electronics projects. The main purpose of the application is to record the vendor information for the electronics components (part #, description, price, etc.) and organize (associate) them into projects (finished products). One of the requirements is to track changes for any given vendor item (mainly price) and changes at the project level to provide a point-in-time statistics at both component level and project level details for changes. I decided to use Entity Framework 4 for my data access layer with SQL CE 3.5 for the

Foreign key mapping inside Embeddable class

人盡茶涼 提交于 2019-12-03 11:06:56
I am using eclipselink for JPA . I have an entity, which has a composite key fabricated out of two fields. Following is my Embeddable primary key class' fields(members). @Embeddable public class LeavePK { @ManyToOne(optional = false) @JoinColumn(name = "staffId", nullable = false) private Staff staff; @Temporal(TemporalType.TIMESTAMP) private Calendar date; //setters and getters } My entity is going to hold leave data related to a staff, so I am trying to combine staff object and leave date to produce composite key. Apart from my logic, it is not allowing me to have a foreign key mapping

ASP.NET MVC : Generating multi level menu using recursive helpers

╄→尐↘猪︶ㄣ 提交于 2019-12-03 09:00:52
I am using this code for generating menu, this menu populates items from database (Category Table) using this technique Partial View : @using SarbarzDarb.Helper @model IEnumerable<SarbarzDarb.Models.Entities.Category> @ShowTree(Model) @helper ShowTree(IEnumerable<SarbarzDarb.Models.Entities.Category> categories) { foreach (var item in categories) { <li class="@(item.ParentId == null && item.Children.Any() ? "dropdown-submenu" : "")"> @Html.ActionLink(item.Name, actionName: "Category", controllerName: "Product", routeValues: new { Id = item.Id, productName = item.Name.ToSeoUrl() },

Entity Framework Code First Mapping

半世苍凉 提交于 2019-12-03 08:30:33
I have two classes, the Group class has a many to many relationship with the User class (representing the groups a user belongs to) and then the group also has a relationship of one to many with the user class (representing the owner of a group). How can I map this? public class User { public int Id { get; set; } public string Avatar { get; set; } public string Name { get; set; } public string Message { get; set; } public virtual ICollection<Group> OwnedGroups { get; set; } public virtual ICollection<Group> Groups { get; set; } } public class Group { public int Id { get; set; } public DateTime